I am confused with SQL command differences

时间:2015-10-06 08:39:57

标签: plsql

Why would you use insert into dept values didbuild; instead of insert into dept values did_insrt in the following code?:

SET SERVEROUTPUT ON;

declare

did_insrt dept%rowtype;

Begin

did_insrt.did := 4;

did_insrt.dname := 'accounting';

insert into dept values didbuild;

end;


Select * from dept;

1 个答案:

答案 0 :(得分:0)

It should be did_insrt.

If record variable is created using the %ROWTYPE command then we would be able to insert record directly into the table.

declare

did_insrt dept%rowtype;

Begin

did_insrt.did := 4;

did_insrt.dname := 'accounting';

insert into dept values did_insrt;

commit;

end;