From: Henry Ortega <juandelacruz@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: insert only if conditions are met?
Date: Wed, 31 Aug 2005 11:49:44 -0400
Message-ID: <2bffcc3305083108497ea6dcc6@mail.gmail.com> (raw)
In-Reply-To: <2bffcc3305083108487fb80cb2@mail.gmail.com>
References: <2bffcc33050831080942f806e1@mail.gmail.com>
<20050831152534.GA18934@winnie.fuhr.org>
<2bffcc3305083108487fb80cb2@mail.gmail.com>
What I am trying to do is
* Insert a record for EMPLOYEE A to TABLE A
IF
the sum of the hours worked by EMPLOYEE A on TABLE A
is not equal to N
Is this possible?
>
>
>
> On 8/31/05, Michael Fuhr <mike@fuhr.org> wrote:
> >
> > On Wed, Aug 31, 2005 at 11:09:54AM -0400, Henry Ortega wrote:
> > > 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 )
> >
> > See the INSERT documentation; it mentions inserting values from a
> > subquery.
> >
> > INSERT INTO employee
> > SELECT 'lastname', 'firstname', 8
> > WHERE <condition>;
> >
> > --
> > Michael Fuhr
> >
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: juandelacruz@gmail.com
Subject: Re: insert only if conditions are met?
In-Reply-To: <2bffcc3305083108497ea6dcc6@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox