赞
踩
请支持原创,认准DannisTang(tangweixuan1995@foxmail.com)
在存储过程里面,使用if语法,可以达到判断的效果
如下面例子,我想根据传入参数来执行不同的语句
CREATE OR REPLACE PROCEDURE DEMO(DEMO_FLAG IN VARCHAR2) IS DEMO_DATE DATE; BEGIN IF DEMO_FLAG = '0' THEN SELECT SYSDATE INTO DEMO_DATE FROM DUAL; ELSIF DEMO_FLAG = '1' THEN SELECT SYSDATE INTO DEMO_DATE FROM DUAL; ELSIF DEMO_FLAG = '2' THEN SELECT SYSDATE INTO DEMO_DATE FROM DUAL; ELSE SELECT SYSDATE INTO DEMO_DATE FROM DUAL; END IF; END DEMO;
这样话,直接运行这个存过,再输入传入的参数即可
begin
-- Call the procedure
demo(demo_flag => : /*这里输入即可*/);
end;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。