PLSQL的 dynamic sql小例子

SET serveroutput ON; DECLARE p_tab_name varchar2(20); cursor_name INTEGER; p_rows_del INTEGER; BEGIN p_tab_name := \'EMP_CPY\'; cursor_name := DBMS_SQL.OPEN_CURSOR; DBMS_SQL.PARSE(cursor_name, \'DELETE FROM \'||p_tab_name, DBMS_SQL.NATIVE); DBMS_OUTPUT.PUT_LINE(\'p_tab_name:\'|| p_tab_name); p_rows_del := DBMS_SQL.EXECUTE (cursor_name); DBMS_SQL.CLOSE_CURSOR(cursor_name); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE(SUBSTR(SQLERRM,1,100)); END;

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwygsj.html