Hello,
I created my custom record type (t_Emp) where for example last two fields contain default values. If I insert values into record fields separately predefined default values are inserted ok. But if I want to insert same values directly into the record (r_Emp) I get error. Do you have to list all fields (as in case1) if you have some predefined values for some fields, or I use some wrong syntax? If you have many fields with some predefined values, code is then that way much longer.
Declare
Type t_Emp Is Record(
Nr Number,
Name VarChar2(20),
Job VarChar2(15) Not Null := 'Unknown',
Sal Number Default 111
);
r_Emp t_Emp;
Begin
-- This working
Select 1000, 'Doe'
Into
r_Emp.Nr,
r_Emp.Name
From Dual;
DBMS_OutPut.Put_Line('r_Emp: ' || r_Emp.Nr || ', ' || r_Emp.Name || ', ' || r_Emp.Job || ', ' || r_Emp.Sal);
-- Return Ok: r_Emp: 1000, Doe, Unknown, 111
-- Why this doesn't working?
Select 1000, 'Doe', 'Sales'
Into r_Emp
From Dual;
DBMS_OutPut.Put_Line('r_Emp: ' || r_Emp.Nr || ', ' || r_Emp.Name || ', ' || r_Emp.Job || ', ' || r_Emp.Sal);
-- Return Error: PL/SQL: ORA-00913: too many values
End;
/
BB