I am trying to write a procedure where I use Subquery Factoring 'WITH .. AS', but when I use 'IF .. THEN' before it, I get syntax error, I don't know how should I write it, any help?
BEGIN
OPEN my_SYS_REFCURSOR FOR
IF .. IS NULL
THEN
WITH SomeName
AS (SELECT.....);
You simply need to separate the
IF
statement from theOPEN
: