17,086
社区成员
发帖
与我相关
我的任务
分享
话说,虽然Oracle没有if exists(...)
但是我能可以这样写
declare v_count int;
begin
select count(*) into v_count from t1;
if v_count > 0 then
select * from table 1
else
select * from table 2
end if;
end;
DECLARE
v_tmp NUMBER := 0;
v_result NUMBER;
BEGIN
SELECT COUNT(* ) INTO v_tmp FROM student;
IF v_tmp <= 0 THEN
dbms_output.put_line('execute table2');
ELSE
dbms_output.put_line('execute table1');
END IF;
END;
http://bbs.csdn.net/topics/392138410#new_post
select * from DEPT2
UNION
select * from DEPT WHERE 0 = (select COUNT(*) from DEPT2)