Skip to Main Content

Breadcrumb

XMAS_TREE

The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments. Please have a happy and safe festive season and as always, thanks for being a member of the AskTOM community.

Question and Answer

Chris Saxon

Thanks for the question, Sergiu.

Asked: August 04, 2017 - 11:57 am UTC

Last updated: August 04, 2017 - 3:56 pm UTC

Version: oracle 11g

Viewed 10K+ times! This question is

You Asked

How can I use a SELECT CASE INTO to store a value in a local variable?


and Chris said...

Like you'd select any other column or expression into a variable!

You put your case statement in the select clause and into after between the select and from clauses:

set serveroutput on
declare
  l varchar2(10);
begin
  select case when 1=1 then 'THIS' else 'THAT' end 
  into   l from dual;
  
  dbms_output.put_line(l);
end;
/

THIS


We're not taking comments currently, so please try again later if you want to add a comment.

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library