oracle存储过程 本帖最后由 pchyping 于 2013-04-03 12:23:11 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 k_date:='select sysdate+v1 from dual'; num:='select count(1) from all_tables where TABLE_NAME='||'''tablename''';这两个写法好奇怪啊…… 还有if ...else if ...end if;这又是什么的语法?你编译这个过程时,会给你报很多语法错误的,对照着改吧。 我改过了,你给我看看create or replace procedure test_droptable ( dbname varchar2,/*传入数据库名称参数*/ tablename varchar2,/*传入表名参数*/ v1 int/*时间偏移量*/ )as k_date date; q_sqlstr varchar2(200); num int; begin /*执行语句块*/ /* step1: 获得系统时间 根据系统时间来加上偏移量得到要执行的时间变量 _date step2: 判断数据库中是否有这张表 yes:拼接sql语句 drop table schema.table_name||_date no:直接返回 step3:执行sql step4:如有异常则输出‘在RUNPROCEDURE过程中出错!’ */ k_date:='select sysdate+v1 from dual'; num:='select count(1) from all_tables where TABLE_NAME='||'''tablename'''; if (num=1) then q_sqlstr:='drop table schema.tablename'||k_date; execute immediate q_sqlstr; else return; end if; exception when others then DBMS_OUTPUT.PUT_LINE('在RUNPROCEDURE过程中出错!'); end; 把基本PL/SQL语法重新学一次。 自主事务处理在什么时候使用? ORA-12541: TNS: 没有监听器 各位大哥救救小弟!关于不同表空间的问题? sql问题!显示最近的三条记录 怎样写一条SQL语句,查出两个表的并集???? 两个表中选取数据的问题?急!谢谢! oracle中如何定义整型字段? (500分)求高效分页,各种方法均可?(表如下) oracle中照片字段用 blob,但用select *查询的时候,他说“列或属性类型无法通过 SQL*Plus 显示”? 急!求教各位高手 Oracle 序列起始默认值的问题 plsql 无法弹出数据表对应的字段
num:='select count(1) from all_tables where TABLE_NAME='||'''tablename''';这两个写法好奇怪啊……
else if ...
end if;这又是什么的语法?你编译这个过程时,会给你报很多语法错误的,对照着改吧。
create or replace procedure test_droptable
(
dbname varchar2,/*传入数据库名称参数*/
tablename varchar2,/*传入表名参数*/
v1 int/*时间偏移量*/
)
as
k_date date;
q_sqlstr varchar2(200);
num int;
begin
/*执行语句块*/
/*
step1: 获得系统时间
根据系统时间来加上偏移量得到要执行的时间变量 _date
step2: 判断数据库中是否有这张表
yes:拼接sql语句 drop table schema.table_name||_date
no:直接返回
step3:执行sql
step4:如有异常则输出‘在RUNPROCEDURE过程中出错!’ */
k_date:='select sysdate+v1 from dual';
num:='select count(1) from all_tables where TABLE_NAME='||'''tablename''';
if (num=1) then
q_sqlstr:='drop table schema.tablename'||k_date;
execute immediate q_sqlstr;
else
return;
end if;
exception
when others then
DBMS_OUTPUT.PUT_LINE('在RUNPROCEDURE过程中出错!');
end;