From: | Darren Ferguson <darren(at)crystalballinc(dot)com> |
---|---|
To: | Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Triggers |
Date: | 2002-08-16 14:33:19 |
Message-ID: | Pine.LNX.4.44.0208161031390.20926-100000@thread.crystalballinc.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
You can make the trigger fire before you do the insert and make sure you
get the value and then insert into the table.
Seems really odd that you would do it this way. I can't think why you
would not get the value first and then insert inot the table. I am
assuming you get the value via (a).
Anyway the first paragraph should give you the answer
HTH
On Fri, 16 Aug 2002, Jean-Christian Imbeault wrote:
> I have a with a a column defined as not null. The value however can be
> found by looking it up in another table. I would like to create a
> trigger that after insert would look up the need value and put it in the
> record being inserted.
>
> Unfortunately the column is defined as not null so I fear the insert
> would fail and the trigger never get called. How can I get around this?
>
> i.e.
>
> create table t {
>
> id serial primary key,
> a integer not null,
> b integer not null -- b can be found in another table
> };
>
> insert into t(a) values('1'); -- this would start the trigger and turn
> the insert into:
>
> insert into t(a,b) values('1', 'some value from another table');
>
> Are thriggers the wrong way to go about this?
>
> Jc
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>
--
Darren Ferguson
From | Date | Subject | |
---|---|---|---|
Next Message | Jean-Christian Imbeault | 2002-08-16 14:36:12 | Re: Triggers |
Previous Message | Jean-Christian Imbeault | 2002-08-16 14:27:27 | Re: Triggers |