Subquery Factoring 'WITH .. AS' を使用するプロシージャを作成しようとしていますが、その前に 'IF .. THEN' を使用すると構文エラーが発生し、どのように記述すればよいかわかりません。 ?
BEGIN
OPEN my_SYS_REFCURSOR FOR
IF .. IS NULL
THEN
WITH SomeName
AS (SELECT.....);
Subquery Factoring 'WITH .. AS' を使用するプロシージャを作成しようとしていますが、その前に 'IF .. THEN' を使用すると構文エラーが発生し、どのように記述すればよいかわかりません。 ?
BEGIN
OPEN my_SYS_REFCURSOR FOR
IF .. IS NULL
THEN
WITH SomeName
AS (SELECT.....);
IF
ステートメントを次のものから分離するだけですOPEN
。
declare
my_sys_refcursor sys_refcursor;
begin
if (1=1) then /* condition satisfied, cursor from some table */
open my_sys_refcursor for
with somename as ( select '1' as one from dual)
select one
from somename;
else /* condition not satisfied, select from different tables */
open my_sys_refcursor for
with someOthername as ( select 'one' as one from dual)
select one
from someOthername;
end if;
end;