Re: insert only if conditions are met?

Поиск
Список
Период
Сортировка
От Henry Ortega
Тема Re: insert only if conditions are met?
Дата
Msg-id 2bffcc33050831094957be1b4a@mail.gmail.com
обсуждение исходный текст
Ответ на Re: insert only if conditions are met?  (Ragnar Hafstað <gnari@simnet.is>)
Ответы Re: insert only if conditions are met?  ("Jim C. Nasby" <jnasby@pervasive.com>)
Re: insert only if conditions are met?  (Ragnar Hafstað <gnari@simnet.is>)
Re: insert only if conditions are met?  (Daryl Richter <daryl@brandywine.com>)
Список pgsql-sql
Ok. Here's TABLE A

emp            date             hours       type
JSMITH       08-15-2005   5             WORK
JSMITH       08-15-2005   3             WORK
JSMITH       08-25-2005   6             WORK

I want to insert the ff:
1.) JSMITH    08-15-2005    8    VAC
2.) DOE        08-16-2005    8    VAC

#1 should fail because there is already 8 hours entered as being
Worked on 08-15-2005 (same date).

Any suggestions?



On 8/31/05, Ragnar Hafstað <gnari@simnet.is> wrote:
On Wed, 2005-08-31 at 11:49 -0400, Henry Ortega wrote:
> 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?

Sure, given a suitable schema

It is not clear to me, if the hours worked are
to be found in the same table you want to insert
into, or not.

gnari




В списке pgsql-sql по дате отправления:

Предыдущее
От: Ragnar Hafstað
Дата:
Сообщение: Re: insert only if conditions are met?
Следующее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: insert only if conditions are met?