I have a function which has three If/Then statements before opening a cursor. The If/Then statements check validity prior to opening the cursor.
I would like to add one more If/Then validity check, however, it is a bit more complicated than the others. Below is a sample, and I have block commented what I would like to add:
begin
if not procedure.validation_function (<variable>, <condition>=TRUE) then
return variable2;
end if;
/* if not exists
(
SELECT 'x' FROM table1
WHERE table1_id = variable1_id
AND trunc(sysdate) < trunc(table1_date + 60)
) then
return variable2;
end if; */
open cursor(<argument>);
fetch cursor into <variable>;
close cursor;
return <variable>;
end;
My problem is that I come from a T-SQL world, and I am finding in PL/SQL the if not exists command does not work. Is there a way I can, from within the function, have an If NO_DATA_FOUND statement where I utilize SELECT?
Is there a way to nest another function within that, so I can:
begin
SELECT ....
FROM ....
WHERE ....
if NO_DATA_FOUND then
return variable2;
end if;
end;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…