Received: from victoria.host4u.net (victoria.host4u.net [216.71.64.77]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f6PDA4f16603; Wed, 25 Jul 2001 09:10:04 -0400 (EDT) (envelope-from mcurley@e4media.com) Received: from morganc.e4media.com (adsl-162-83-164-253.nyc.adsl.bellatlantic.net [162.83.164.253]) by victoria.host4u.net (8.8.5/8.8.5) with ESMTP id IAA17695; Wed, 25 Jul 2001 08:08:20 -0500 Message-Id: <4.3.2.7.2.20010725085946.023e24a8@e4media.com> X-Sender: mcurley@e4media.com X-Mailer: QUALCOMM Windows Eudora Version 4.3.2 Date: Wed, 25 Jul 2001 09:09:54 -0400 To: , From: Morgan Curley Subject: Re: Inserts in triggers Follow Up In-Reply-To: <009301c114e7$dd2e8960$1001a8c0@archonet.com> References: <4.3.2.7.2.20010725030649.024f7de8@e4media.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=====================_173738622==_.ALT" X-Archive-Number: 200107/907 X-Sequence-Number: 13027 --=====================_173738622==_.ALT Content-Type: text/plain; charset="us-ascii"; format=flowed Well, I couldn't figure out why my INSERT INTO wasn't working so I went with using EXECUTE and concat'ing everything together. One other problem I am having in that proc is SELECT'ing INTO a var. declare id lookup_sports.sport_id%TYPE; begin SELECT INTO id sport_id FROM lookup_sports WHERE....some clause id is always null but the following works declare rs RECORD; id lookup_sports.sport_id%TYPE; begin SELECT INTO rs * FROM lookup_sports WHERE....some clause id := rs.sport_id this doesn't work either SELECT INTO rs sport_id FROM lookup_sports WHERE....some clause Any ideas Thanks, Morgan P.S. good suggestion to differentiate my vars from my columns. For the sake of expediency I named them the same so when I was writing the insert statements I could just copy/past my columns list into my values list. Morgan At 04:56 AM 7/25/2001, Richard Huxton wrote: >From: "Morgan Curley" > > > Are there server setting that need to be set in order to do inserts from > > trigger functions? > >Don't think so. Triggers run with the permissions of the creator, not the >caller though so you might want to look into that. > > > I keep getting: ERROR: parser: parse error at or near "$1" > > and the DEBUG log entry points to the line with the insert on it. > > i.e. > >Could you quote a few lines of code either side - especially something with >the $1 > > > INSERT events ( event_id, sport_id ,name ,feed_code, start_time, > > active_flag, create_timestamp, update_timestamp ) VALUES ( event_id > > ,sport_id ,feed_code ,feed_code, create_timestamp, 1, create_timestamp, > > create_timestamp ); > > > > where the values list is a list of predefined vars. > >Well it should be INSERT INTO ... but I presume this is a cut & paste issue. > >So you have variable names the same as all the field names? I'd probably >change them (stick v_ on the front or something). Even if plpgsql doesn't >get confused readers will. > >- Richard Huxton > > >---------------------------(end of broadcast)--------------------------- >TIP 5: Have you checked our extensive FAQ? > >http://www.postgresql.org/users-lounge/docs/faq.html --=====================_173738622==_.ALT Content-Type: text/html; charset="us-ascii" Well, I couldn't figure out why my INSERT INTO wasn't working so I went with using EXECUTE and concat'ing everything together.

One other problem I am having in that proc is SELECT'ing INTO a var.

declare
        id lookup_sports.sport_id%TYPE;
begin
        SELECT INTO id sport_id FROM lookup_sports WHERE....some clause

id is always null


but the following works
 declare
        rs      RECORD;
        id      lookup_sports.sport_id%TYPE;
begin
        SELECT INTO rs * FROM lookup_sports WHERE....some clause
        id := rs.sport_id

this doesn't work either
        SELECT INTO rs sport_id FROM lookup_sports WHERE....some clause


Any ideas

Thanks,
Morgan

P.S.
good suggestion to differentiate my vars from my columns. For the sake of expediency I named them the same so when I was writing the insert statements I could just copy/past my columns list into my values list.

Morgan

At 04:56 AM 7/25/2001, Richard Huxton wrote:
From: "Morgan Curley" <mcurley@e4media.com>

> Are there server setting that need to be set in order to do inserts from
> trigger functions?

Don't think so. Triggers run with the permissions of the creator, not the
caller though so you might want to look into that.

> I keep getting:  ERROR:  parser: parse error at or near "$1"
> and the DEBUG log entry points to the line with the insert on it.
> i.e.

Could you quote a few lines of code either side - especially something with
the $1

> INSERT events ( event_id, sport_id ,name ,feed_code, start_time,
> active_flag, create_timestamp, update_timestamp ) VALUES ( event_id
> ,sport_id ,feed_code ,feed_code, create_timestamp, 1, create_timestamp,
> create_timestamp );
>
> where the values list is a list of predefined vars.

Well it should be INSERT INTO ... but I presume this is a cut & paste issue.

So you have variable names the same as all the field names? I'd probably
change them (stick v_ on the front or something). Even if plpgsql doesn't
get confused readers will.

- Richard Huxton


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html
--=====================_173738622==_.ALT--