Insert using bind variables
900903Aug 1 2012 — edited Aug 3 2012I 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