Subject [Fwd: "Illegal" subquery in if-clause]
Author Urs Liska
Hello,

I have a problem with a trigger.

I wanted to do a check with a subquery in an if-clause:

IF (NEW.ausgabe_id IN
(SELECT ausgabe_id
FROM sp_gedicht_ausgabenid(NEW.gedicht_id)))

But on compiling the trigger I get an error message that the subquery is
"illegal in this context".


I can achieve the same result with the following loop that iterates
through the ID values that are returned by the SP sp_gedicht_ausgabenid:

...
tmp = 0;
FOR
SELECT ausgabe_id FROM sp_gedicht_ausgabenid(NEW.gedicht_id)
INTO :loc_ausgabe
DO
IF (:LOC_AUSGABE = NEW.ausgabe_id) THEN TMP = 1;

IF (:TMP = 0)
...

Can you tell me why the subquery - that would be much more elegant and
would represent the case much better - is not possible?
Is it not possible at all or can I do something in a different way?

Regards and thanks
Urs