Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / PL SQL Statements
 

Reusing Bind Variables in Dynamic PLSQL

SQL> SQL> declare   2      a NUMBER:=2;   3      b NUMBER:=3;   4      v_plsql_tx VARCHAR2(2000);   5  begin   6      v_plsql_tx := 'BEGIN ' || ' :1 := :1 + :2; ' || 'END;';   7      execute immediate v_plsql_tx   8      using in out a, b;   9      DBMS_OUTPUT.put_line('a='||a);  10  end;  11  / a=5 PL/SQL procedure successfully completed. In dynamic PL/SQL blocks, Oracle counts only unique bind variables and associates them with arguments in the order of their appearance.