Re: [SQL] EXISTS
On Saturday 11. October 2008, Denis Woodbury wrote: >Hi, > >I would like to know if this this type of statement can be used in >Postgresql > >IF NOT EXISTS (SELECT 1 FROM Table WHERE col1 = 'mystring' ) >BEGIN >... >END > >If it can, any idea why I get this error. >** Error ** > >ERROR: syntax error at or near "IF" >SQL state: 42601 >Character: 2 CASE IF NOT (SELECT 1 FROM Table WHERE col1 = 'mystring' ) THEN BEGIN ... END [ELSE BEGIN ... END]; -- Leif Biberg Kristensen | Registered Linux User #338009 Me And My Database: http://solumslekt.org/blog/ -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
[SQL] EXISTS
Hi, I would like to know if this this type of statement can be used in Postgresql IF NOT EXISTS (SELECT 1 FROM Table WHERE col1 = 'mystring' ) BEGIN ... END If it can, any idea why I get this error. ** Error ** ERROR: syntax error at or near "IF" SQL state: 42601 Character: 2 Thanks denis woodbury [EMAIL PROTECTED] 450-242-0249 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
Re: [SQL] EXISTS
Denis Woodbury <[EMAIL PROTECTED]> writes: > I would like to know if this this type of statement can be used in > Postgresql > IF NOT EXISTS (SELECT 1 FROM Table WHERE col1 = 'mystring' ) > BEGIN > ... > END I suspect you are trying to type that directly into SQL. You need to be using plpgsql in order to use procedural logic (ie, if/then). regards, tom lane -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql