Re: insert only if conditions are met? - Mailing list pgsql-sql

From Tom Lane
Subject Re: insert only if conditions are met?
Date
Msg-id 2099.1125501741@sss.pgh.pa.us
Whole thread Raw
In response to insert only if conditions are met?  (Henry Ortega <juandelacruz@gmail.com>)
List pgsql-sql
Henry Ortega <juandelacruz@gmail.com> writes:
> Is there a way to insert a record only if a certain
> condition is met?

> Something like:
> insert into employee values('lastname','firstname',8) where
> (condition here.. select sum(ofsomething) from xx where sum(ofsomething)>0 =
> )

> Is this possible at all with just plain SQL?

Instead of INSERT ... VALUES, use INSERT ... SELECT.
        regards, tom lane


pgsql-sql by date:

Previous
From: Joost Kraaijeveld
Date:
Subject: Re: [GENERAL] How do I copy part of table from db1 to db2
Next
From: Michael Fuhr
Date:
Subject: Re: insert only if conditions are met?