This step fails with "ORA-01006: bind variable does not exist". The problem is that my dynamic block string uses the same placeholder twice ":numval". With a dynamic DML statement (insert, update, etc.), variables are assigned to placeholders by position. Four placeholders? Then four variables in USING list, regardless of the names of placeholders. With dynamic PL/SQL, it's different. Binding is by name. So once I've provided 10000 for the first :numval, it will be used for the second as well. Incorrect Execution of Dynamic Block DECLARE
l_total_salary NUMBER;
BEGIN
EXECUTE IMMEDIATE
'begin dyn_binds (:colname, :numval, :total_salary, :numval); end;'
USING IN 'salary',
IN 10000,
OUT l_total_salary,
IN 100;
DBMS_OUTPUT.put_line (l_total_salary);
ROLLBACK;
END;
|