Re: if exists select ... in plpgsql code - Mailing list pgsql-general

From Tom Lane
Subject Re: if exists select ... in plpgsql code
Date
Msg-id 24876.1031719067@sss.pgh.pa.us
Whole thread Raw
In response to if exists select ... in plpgsql code  (Roland Roberts <roland@astrofoto.org>)
Responses Re: if exists select ... in plpgsql code  (Roland Roberts <roland@astrofoto.org>)
List pgsql-general
Roland Roberts <roland@astrofoto.org> writes:
>             if (exists select id from deepsky where catalog = NEW.catalog and entry = NEW.entry and suffix is null
andcomponent is null) then 

> postgresql doesn't like the "if (exists select id from ...)".

Should be "if (exists (select ...))".  Note the parens in SQL92:

         <exists predicate> ::= EXISTS <table subquery>

         <table subquery> ::= <subquery>

         <subquery> ::= <left paren> <query expression> <right paren>

            regards, tom lane

pgsql-general by date:

Previous
From: Roland Roberts
Date:
Subject: if exists select ... in plpgsql code
Next
From: tony
Date:
Subject: OT: amazon problem