有没有办法在INTO声明中做一个案例?
Create or replace procedure example
AS
Variable1 varchar;
Variable2 varchar;
BEGIN
Select (CASE WHEN number = 1 THEN
This_thing INTO Variable1
ELSE
That_thing INTO Variable2) The_Other
FROM table;
END;
答案 0 :(得分:5)
我们无法从单个CASE()语句中获取两个输出。您可以实现的最佳目标是具有两个具有互斥条件的单独呼叫:
create or replace procedure example as
variable1 t69.this_thing%type;
variable2 t69.that_thing%type;
begin
select (case when whatever = 1 then
this_thing
else
null
end )
, (case when whatever != 1 then
that_thing
else
null
end )
into variable1, variable2
from t69;
end;
/
答案 1 :(得分:2)
不,但你可以这样:
declare
Variable1 varchar2(30);
Variable2 varchar2(30);
BEGIN
Select decode(dummy,'X','This_thing'),
decode(dummy,'X',null,'That_thing')
INTO Variable1,Variable2
FROM dual;
END;