Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Insert using bind variables

900903Aug 1 2012 — edited Aug 3 2012
I am executing bind_test.sql with following parameters from sql-plus. The script execute without an error. However, it does not insert a row in the table.


bind_test.sql 20100912 1 1001;


bind_test.sql
----------------------------------------------------------
set serveroutput on

declare

X VARCHAR2(31);
Y NUMBER;
Z NUMBER;

begin

dbms_output.enable(10000);
X :='&1';
Y :=&2;
Z :=&3;

insert into test
values (TO_DATE (X, 'YYYYMMDD') , Y, Z, null, null, null);


commit;


dbms_output.put_line('var1 = '||X|| ' var2 = ' || Y || ' var3 = '|| Z);

end;
/

----------------------------------
Output:
old 10: X :='&1';
new 10: X :='20100912';
old 11: Y :=&2;
new 11: Y :=1;
old 12: Z :=&3;
new 12: Z :=1001;
var1 = 20100912 var2 = 1 var3 = 1001

PL/SQL procedure successfully completed.
---------------------------------------

select * from test;

no rows selected


Why it is not inserting a row? What could be the reason?

Thanks in advance.
Amit
This post has been answered by Billy Verreynne on Aug 2 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 31 2012
Added on Aug 1 2012
16 comments
4,582 views