7

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

Jonas
  • 121,568
  • 97
  • 310
  • 388
zac
  • 4,495
  • 15
  • 62
  • 127

2 Answers2

7

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.

ain
  • 22,394
  • 3
  • 54
  • 74
3

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

Andrej Kirejeŭ
  • 5,381
  • 2
  • 26
  • 31