CASE WHEN…INTO - Stored Procedure

is there any way to do a CASE WHEN INTO Statement?

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;

Answers


We cannot get two outputs from a single CASE() statement. The best you can achieve is having two separate calls with mutually exclusive conditions:

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;
/

Need Your Help

Make .NET snipping tool compatible with multiple monitors

.net screen screenshot capture

An alternative snipping tool solution was provided in this posting: .NET Equivalent of Snipping Tool

subset of array in golang

python arrays pointers go

I am trying to write the equivalent of the following line in python

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.