oracle 存储过程 怎么少用 if then
比方说句子select a from tab_x
我想在句子有记录返回的时候执行 select b from tab_y
无记录的时候 select c from tab_z
其他错误的时候报错
怎么写句子简洁点呢
一大串if then esle 太无聊了。。。
begin
begin
select ......
exception
when no_data_found then --找不数据的判断
select ...
end;
select ... ----这里no_data_found的时候时候不要执行的
exception
when others then
raise ;
end;
这样写不对的
[解决办法]
我的异常网推荐解决方案:oracle存储过程,http://www.myexception.cn/oracle-develop/177537.html
[解决办法]
我習慣用指針,你可以試一試
CREATE OR REPLACE PROCEDURE MyTable
IS
CURSOR rs IS SELECT a FROM tab_x;
ee rs%ROWTYPE;
begin
OPEN rs;
FETCH rs INTO ee;
IF (rs%found) THEN --找到記錄
WHILE (rs%found) LOOP
SELECT b FROM tab_y;
FETCH rs INTO ee;
END LOOP;
ELSE --沒有找到記錄
SELECT c FROM tab_z;
END IF;
CLOSE rs;
END MyTable;
oracle 存储过程 如何少用 if then
oracle 存储过程 怎么少用 if then比方说句子selectafromtab_x我想在句子有记录返回的时候执行selectbfrom
