I have the following custom RECORD TYPE:
TYPE TB48_RECTYPE IS RECORD (
codpo varchar2(5 BYTE),
codco varchar2(5 BYTE),
quadr varchar2(5 BYTE),
espec varchar2(5 BYTE),
aperf varchar2(5 BYTE),
subes varchar2(5 BYTE),
datin date);
And now a function that returns the exact same type.
function retorna_infos_tabela_48(i_nip in varchar2) return TB48_RECTYPE is
retorno_REC TB48_RECTYPE;
begin
select m.CODPO,
m.CODCO,
m.QUADR,
m.ESPEC,
m.APERF,
m.SUBES,
m.DATIN
into retorno_REC
from TB48_M m
where m.NRO = i_nip;
return retorno_REC;
end retorna_infos_tabela_48;
However, (and this has cost me more than 4 hours already), when I try and run it like this:
DECLARE
TYPE TB48_RECTYPE IS RECORD (
codpo varchar2(5 BYTE),
codco varchar2(5 BYTE),
quadr varchar2(5 BYTE),
espec varchar2(5 BYTE),
aperf varchar2(5 BYTE),
subes varchar2(5 BYTE),
datin date);
RetVal TB48_RECTYPE;
I_NIP VARCHAR2(200);
BEGIN
I_NIP := '88888888';
RetVal := RETORNA_INFOS_TABELA_48 ( I_NIP );
COMMIT;
END;
I get the following error message: PLS-00382: expression is of wrong type. (on the line that I assign the function returned value to the RetVal variable)
I mean, the function returns a RECORD which is of the exact same type as the variable I’ve declared!! What am I missing here???
Thanks (and a few REP points) in advance.!
I suspect your problem is that you attempting to place a globally declared type into a locally declared one.
I think if you change your procedure to the following it should work.
Currently your
commitis doing nothing…You haven’t provided how you created your global type, but if you didn’t do it in a package then the provided syntax is incorrect; are you sure it compiled?