Reputation: 11
create or replace procedure add1(id1 integer, id integer)
as
begin
execute immediate 'create table section2(id integer)';
execute immediate 'insert into section2 values(id1)';
end;
displays
[ERR-312BA : Column not allowed here:
0001 : insert into Section2 values(ID) ^ ^
I want to insert directly not values but through variables
Upvotes: 1
Views: 72
Reputation: 726499
This is because values
expects literal constants and parameters of the statement being executed. Although id1
is a parameter, it belongs to the stored procedure, not to the INSERT
statement.
Try this statement instead:
execute immediate 'INSERT INTO section2(id) VALUES (:1)' USING id1;
Now id1
becomes a value of the parameter :1
, so the statement should run correctly.
Upvotes: 1