Pergunta

I'm calling a function that returns a type of table.

My function receives a variable of the type varchar. Because i return a type that i created i had to make cast and multiset...
My problems is that, the select inside my multiset executes without problem outside of the function, but when i execute my function it gives me ORA-22814 attribute or element value is larger than specified in type error. NOTE: i always run the script with the same variable value

Type OBJECT:

create or replace
TYPE Z_PEDIDO_SeB IS OBJECT(
Contrato varchar2(4000 BYTE),
DataObjectivo date,
DataObjectivoSpecified date,
Descricao varchar2(500 BYTE),
DireccaoRequerente varchar2(50 BYTE),
Empresa varchar2(50 BYTE),
Estado varchar2(50 BYTE),
GestorDDS varchar2(100 BYTE),
GestorEncomenda varchar2(30 BYTE),
Referencia varchar2(50 BYTE),
Link varchar2(500 BYTE),
ObsComite varchar2(4000 BYTE),
OutrosFornecedores varchar2(4000 BYTE),
OutrosSistAfectados varchar2(4000 BYTE),
PrincipalSistAfectado varchar2(4000 BYTE),
Prioridade varchar2(50 BYTE),
Rede varchar2(50 BYTE),
Requerente varchar2(100 BYTE),
TestesAceitacao varchar2(10 BYTE),
proj_id varchar2(50 BYTE));

Type TABLE:

create or replace
TYPE Z_TABLE_PEDIDO_SeB IS TABLE OF Z_PEDIDO_SeB;

FUNCTION:

create or replace
function Z_GetDadosCreateUpdate_SEB(
    proj_id in varchar2
)
return Z_TABLE_PEDIDO_SeB as
  t_dados   Z_TABLE_PEDIDO_SeB;
begin
  select 
  cast(
  multiset(
--STARTS HERE WHAT I RUN WITHOUT PROBLEM OUTSIDE THE FUNCTION
  select 
(SELECT line_text
from long_text 
where key2 = proj_id and key1 = 'contrato'
) Contrato,
NVL(SCHEDULE_FINISH,ACTUAL_FINISH) DataObjectivo,
NVL(SCHEDULE_FINISH,ACTUAL_FINISH) DataObjectivoSpecified,
pedidos.description as Descricao,
costum.direcaorequerente DireccaoRequerente,
costum.empresa Empresa,
estado.description Estado,
costum.gestordds GestorDDS,
(select recursos.description
from structure recursos,
resources,
workflow,
wf_team
where recursos.structure_code = resources.resource_code
and workflow.planning_code = projectos.structure_code
and wf_team.workflow_id = workflow.workflow_id
and wf_team.lifecycle_role_code = '868'
and wf_team.user_name = resources.LOGON_ID
and rownum = 1
) GestorEncomenda,
pedidos.structure_code ID,
(SELECT line_text
from long_text 
where key2 = proj_id and key1 = 'urlcadernoreq'
) Link,
(SELECT line_text
from long_text 
where key2 = proj_id and key1 = 'observacoescomite'
) ObsComite,
(SELECT line_text
from long_text 
where key2 = proj_id and key1 = 'outrosfornecedores'
) OutrosFornecedores,
(SELECT line_text
from long_text 
where key2 = proj_id and key1 = 'outrossistemas'
) OutrosSistAfectados,
(SELECT line_text
from long_text 
where key2 = proj_id and key1 = 'principalsistema'
) PrincipalSistAfectado,
costum.prioridade Prioridade,
(SELECT rede.description
from structure rede, planning_entity proj
where proj.code88 = rede.structure_code
and proj.planning_code = proj_id
) Rede,
costum.requerente Requerente,
(SELECT rede.description
from structure rede, planning_entity proj
where proj.code89 = rede.structure_code
and proj.planning_code = proj_id
) TestesAceitacao,
projectos. structure_code proj_id
from structure projectos,
planning_entity,
structure pedidos,
structure estado,
custom_data costum
where projectos.structure_code = planning_entity.planning_code
and planning_entity.planning_code = planning_entity.ppl_code
and pedidos.structure_code = planning_entity.code31
and estado.structure_code = planning_entity.code20
and projectos.structure_code = proj_id
and costum.planning_code = proj_id
-- HERE ENDS WHAT I RUN OUTSIDE THE FUNCTION WITHOUT A PROBLEM
    ) 
      as Z_TABLE_PEDIDO_SeB)
    into
      t_dados
    from 
      dual;

  return t_dados;

end Z_GetDadosCreateUpdate_SEB;

What i execute:

SELECT * FROM table (PVDEV.Z_GetDadosCreateUpdate_SEB('184765'));

Error i got:

ORA-22814: valor do atributo ou elemento é superior ao especificado no tipo
ORA-06512: na "PVDEV.Z_GETDADOSCREATEUPDATE_SEB", linha 7
22814. 00000 -  "attribute or element value is larger than specified in type"
*Cause:    Value provided for the object type attribute or collection element
       exceeded the size specified in the type declaration.
*Action:   Choose another value and retry the operation.

NOTE: if i try 18476 instead of 184765 it runs with no problem. So? how did i put such restriction? Where?
NOTE: Now i'm showing the error, the real one, i'm really sorry for the mistake

I would really appreciate any answer as other's people work is waiting for my part :S. Anyway thanks in advance for any information.

Foi útil?

Solução

If I were you I would declared the function as the pipelined one and returned values by pipe row statement. And surely get rid of CAST/multiset. For loop statement is your choice. I'm sure it will work using my piece of advice.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top