I have a regular table called TABLE1 with a column NUMBER(8) and a column varchar2(100).
Now I’ve created an OBJECT TYPE T_MYTYPEwith two attributes: one NUMBER and another varchar2.
In a nutshell, they are exactly the same.
Now I want to do the following.
v_obj T_MYTYPE;
begin
select * into v_obj from TABLE1 t1 where t1.num = 9;--guaranteed to return only ONE row!!
end;
but PL/SQL: ORA-00947: not enough values..
This is quite frustrating… I just want to be able to return ONE row of data into a collection!! Be it a RECORD or a OBJECT TYPE!!, I don’t care… I just can’t seem to make this work..!!!! Can anyone help??
You can. You just need to use the object constructor
In your case, it would be
If all you want to do is select an entire row from a table into a record type, however, then you’d want to do as ruakh suggested and just declare a
%ROWTYPErecord