日期:2014-05-17 浏览次数:21191 次
create or replace procedure pro_trunc is tablename varchar(15) :='URGE_T'; begin --execute immediate 'truncate table '||tablename; --execute immediate 'truncate table urge_t'; execute immediate 'truncate table :1' using tablename; execute immediate 'truncate table :1' using 'urge_t'; end pro_trunc;
SQL> exec pro_trunc; begin pro_trunc; end; ORA-00903: 表名无效 ORA-06512: 在 "QIUYUE.PRO_TRUNC", line 6 ORA-06512: 在 line 1
create or replace procedure pro_trunc is tablename varchar2(15) := 'urge_t'; p_val varchar2(1000); begin execute immediate 'select ''truncate table ''||:1 from dual ' into p_val using tablename; execute immediate p_val; end pro_trunc; / exec pro_trunc;