日期:2014-05-17 浏览次数:20885 次
--创建表 create table STAT_1DAY_DOMAIN_test(id int); / select * from STAT_1DAY_DOMAIN_test; / --创建sp --http://topic.csdn.net/u/20120530/11/3a88bd75-c7b5-4c8e-afe2-80b6872df06a.html?124 create or replace procedure sp_dropTable(v_tbname in varchar2) as v_sql varchar2(4000); begin v_sql:='drop table STAT_1DAY_DOMAIN_'||v_tbname; execute immediate v_sql; end sp_dropTable; / --执行sp begin sp_dropTable('test') ; end; / --查询表 --select * from STAT_1DAY_DOMAIN_test;
------解决方案--------------------
--创建表 create table STAT_1DAY_DOMAIN_test(id int); / select * from STAT_1DAY_DOMAIN_test; / --创建sp create or replace procedure sp_dropTable(v_tbname in varchar2) as v_sql varchar2(4000); begin v_sql:='drop table STAT_1DAY_DOMAIN_'||v_tbname; execute immediate v_sql; --异常处理 EXCEPTION when others then dbms_output.put_line('table not exists'); end sp_dropTable; / --执行sp begin sp_dropTable('test') ; end; / --查询表 --select * from STAT_1DAY_DOMAIN_test;