Skip to content
Advertisement

PL/SQL fill variable with if-condition value

i am trying to fill a variable in PL/SQL with an if-condition value like this:

v_variable := if(4 > 3) THEN 'A' ELSE 'B' END;

but this doesnt work.

Are there any options to do this?

Advertisement

Answer

Instead of doing this with an if, I’d go with case:

 v_variable := case when 4>3 then 'A' else 'B' end;
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement