實作功能:如果表2為空就查表一,否則查詢表1
if exists (select 0 from table2)
select * from table 1
else
select * from table 2
這樣的陳述句實作不了,在oracle中該怎么寫
uj5u.com熱心網友回復:
貼子發重復了declare v_count int;
begin
select count(*) into v_count from t1;
if v_count > 0 then
陳述句1
else
陳述句2
end if;
end;
uj5u.com熱心網友回復:
可以使用存盤程序來判斷declare number int
begin
select count(*)number from 表2
if number>0 then
select * from 表2
else
select * from 表1
end if
end
uj5u.com熱心網友回復:
用存盤程序,類似于函式。上面版主給的是最佳
uj5u.com熱心網友回復:
declare v_count int;begin
select count(*) into v_count from t1;
if v_count > 0 then
陳述句1
else
陳述句2
end if;
end;
-----------------------------------轉載樓上
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/90772.html
標籤:基礎和管理
上一篇:Oracle 條件判斷怎么寫
下一篇:初學,有疑問請大神解答
