Re: Trigger Question

From: Terry Lee Tucker <terry(at)esc1(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Trigger Question
Date: 2005-01-05 22:35:18
Message-ID: 200501051735.18794.terry@esc1.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Now why didn't I think of that? That's exactly what I need to do. Thanks to
all who responded ;o)

On Wednesday 05 January 2005 05:09 pm, Alex Turner saith:
> Maybe what you want is a stored procedure, not a trigger. A trigger
> will only have the data that is available from the insert operation,
> and the rest of the row that was modified (It really can't have
> anything else if you think about it)
>
> Stored procedures are an exellent way to guarantee atomic access to
> data in an application.
>
> Alex Turner
> NetEconomist
>
> On Wed, 5 Jan 2005 16:35:42 -0500, Terry Lee Tucker <terry(at)esc1(dot)com> wrote:
> > 1) INSERT INTO logs (carr_code, ..., ..., ...) VALUES('ABCDEFG', ...,
> > ...); logs is table A in my question
> >
> > 2) logs_insert fires (This is a AFTER INSERT trigger)
> >
> > 3) in this trigger, I need to do the following:
> > update avlds set carr_code = new.carr_code where avlds.recid =
> > ??; avlds is table B in my question
> > The questions marks indicate the first piece of data that I want
> > to dynamically pass to the trigger.
> >
> > 4) in the same trigger:
> > update tract set order_num = avlds.order_num where tract.recid =
> > ??; tract is table C in my question
> > The question marks refer to the second piece of data that I want
> > to pass dynamically into the trigger.
> >
> > In other terms, when the user creates a logs record that assigns a truck
> > to a load, I need to update specific rows in two other tables, avlds, and
> > tract. I was wanting to do this from the trigger level, but I will need
> > the unique serial key of each of the existing records in avlds and tract.
> > These two keys comprise the "dynamic" part of the question. I was just
> > wondering if there is some way of passing dynamic data into a trigger. I
> > don't believe there is, but I thought I would ask.
> >
> > Thanks for the input.
> > Work: 1-336-372-6812
> > Cell: 1-336-363-4719
> > email: terry(at)esc1(dot)com
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 8: explain analyze is your friend
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

--
Work: 1-336-372-6812
Cell: 1-336-363-4719
email: terry(at)esc1(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ragnar Hafstað 2005-01-05 22:43:07 Re: SELECT WHERE NOT, is not working
Previous Message Ragnar Hafstað 2005-01-05 22:34:01 Re: Index on a view??