Re: Trigger not working as expected, first row gets a null value

From: novnov <novnovice(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Trigger not working as expected, first row gets a null value
Date: 2007-08-15 01:12:13
Message-ID: 12154927.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


I have been able to spend some more time working on this and have made a bit
of progress.

I had the trigger set to run before insert; and the sql inside the trigger
needed to ref the new record in order to supply a value. I think that's why
the first try always applied a null value.

So I've changed the trigger to go after insert. Now, all of my trigger
function variables are populated properly but the record is never updated.
The function is meant to find a value via the internal sql, and then update
a column in the same tabled that invoked the trigger with that value. Is
that a non-workable scenario? IE, an after insert trigger can't modify a
column in the same table that was updated?

Martijn van Oosterhout wrote:
>
> On Wed, Aug 08, 2007 at 03:20:00PM -0700, novnov wrote:
>>
>> I know that would be best but it'd be a major undertaking to try to repro
>> this situation. I was hoping for some hints, 'it sounds like xyz',
>> because
>> I'm pretty sure I'm just tripping over a commonplace issue.
>
> It doesn't have to be repoducable, but the definition of the tables
> involves + the code of the trigger would help. I read your description
> three times and still couldn't quite work out exactly what the problem
> was or what you were expecting to happen...
>
> Have a nice day,
> --
> Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
>> From each according to his ability. To each according to his ability to
>> litigate.
>
>
>

--
View this message in context: http://www.nabble.com/Trigger-not-working-as-expected%2C-first-row-gets-a-null-value-tf4238812.html#a12154927
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Trevor Talbot 2007-08-15 01:25:05 Re: Moving to postgresql and some ignorant questions
Previous Message Alvaro Herrera 2007-08-15 00:51:57 Re: more select-for-update questions