Declare
tempid table.id%type := 123456789;
Tempname table.name%type := 'Temp';
Begin
select name into tempname from table where id = tempid ;
if Tempname = 'temp' then
tempid := 1;
else
end if
select name from table where id = tempid;
commit;
End;
tempid table.id%type := 123456789;
Tempname table.name%type := 'Temp';
Begin
select name into tempname from table where id = tempid ;
if Tempname = 'temp' then
tempid := 1;
else
end if
select name from table where id = tempid;
commit;
End;
Declare
tempid table.id%type := 123456789;
Tempname table.name%type;
Begin
select name into tempname from table where id = tempid ;
if Tempname = '' then
tempid := 1;
else
end if
select name from table where id = tempid;
commit;
End;
from table
where id = when exists(select 1 from table where id = and rownum <2 ) then 123456789 else 1 end
WHERE (1 <= (SELECT COUNT(*) FROM TABLE WHERE ID = '123456789')
AND ID = '123456789')
OR (0 = (SELECT COUNT(*) FROM TABLE WHERE ID = '123456789')
AND ID = '1')其中上述语句中有三处用到的ID = '123456789' 可换成参数,用你想查的id号替换。
select name
from table
where id =case when exists(select 1 from table where id = and rownum <2 ) then 123456789 else 1 end