gpt4 book ai didi

sql - CASE WHEN...INTO - 存储过程

转载 作者:行者123 更新时间:2023-12-02 07:49:58 25 4
gpt4 key购买 nike

有没有办法做一个 CASE WHEN 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;

最佳答案

我们无法从单个 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;
/

关于sql - CASE WHEN...INTO - 存储过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4342942/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com