实现功能:如果表2为空就查表一,否则查询表1
if exists (select 0 from table2)
select * from table 1
else
select * from table 2
这样的语句实现不了,在oracle中该怎么写
if exists (select 0 from table2)
select * from table 1
else
select * from table 2
这样的语句实现不了,在oracle中该怎么写
begin
select count(*) into v_count from t1;if v_count > 0 then
语句1
else
语句2
end if;
end;
begin
select count(*)number from 表2if number>0 then
select * from 表2
else
select * from 表1
end if
end
begin
select count(*) into v_count from t1;if v_count > 0 then
语句1
else
语句2
end if;
end;
-----------------------------------转载楼上