Re: insert only if conditions are met?

From: Henry Ortega <juandelacruz(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: insert only if conditions are met?
Date: 2005-08-31 15:49:44
Message-ID: 2bffcc3305083108497ea6dcc6@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)fuhr(dot)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
> >
>
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Chris Travers 2005-08-31 16:40:22 Re: insert only if conditions are met?
Previous Message Michael Fuhr 2005-08-31 15:25:34 Re: insert only if conditions are met?