Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebird CASE statement inside stored procedure

I was trying to use the case statement inside a stored procedure but I got "Token unknown" on it. case is not supported in stored procedure? Thanks

like image 969
zac Avatar asked Oct 01 '11 01:10

zac


2 Answers

As Andrei wrote, CASE is only available in SELECT statements. So the trick to use it is to select from some table which has only one row, like RDB$DATABASE:

SELECT
  CASE
    ...
  END
FROM RDB$DATABASE INTO :myVAR;

Of course, this is only usefull in case you want to assign value to a variable based on some conditions, if you need a control flow statement then IF / ELSE ladder is the only option.

like image 133
ain Avatar answered Sep 22 '22 18:09

ain


You can use CASE statement only within SELECT operator. Standalone usage is not allowed.

like image 26
Andrej Kirejeŭ Avatar answered Sep 23 '22 18:09

Andrej Kirejeŭ