Re: if exists select ... in plpgsql code

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Roland Roberts <roland(at)astrofoto(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: if exists select ... in plpgsql code
Date: 2002-09-11 04:37:47
Message-ID: 24876.1031719067@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Roland Roberts <roland(at)astrofoto(dot)org> writes:
> if (exists select id from deepsky where catalog = NEW.catalog and entry = NEW.entry and suffix is null and component 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message tony 2002-09-11 08:54:08 OT: amazon problem
Previous Message Roland Roberts 2002-09-11 03:55:40 if exists select ... in plpgsql code