Received: from sss.pgh.pa.us ([192.204.191.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f6PFW7f44968; Wed, 25 Jul 2001 11:32:07 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id f6PFVoC21319; Wed, 25 Jul 2001 11:31:50 -0400 (EDT) To: Morgan Curley cc: pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: Inserts in triggers In-reply-to: <4.3.2.7.2.20010725030649.024f7de8@e4media.com> References: <4.3.2.7.2.20010725030649.024f7de8@e4media.com> Comments: In-reply-to Morgan Curley message dated "Wed, 25 Jul 2001 03:11:48 -0400" Date: Wed, 25 Jul 2001 11:31:49 -0400 Message-ID: <21316.996075109@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200107/910 X-Sequence-Number: 13030 Morgan Curley writes: > 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. > 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 ); I think your problem is that this gets converted into something along the line of INSERT events ( $1, $2, ...) VALUES ( $1, $2, ...) ie, the plpgsql parser is too stupid to know that it should substitute values for only one set of occurrences of plpgsql variable names, and not the other set. You could check this by running the function with query logging turned on, and seeing what gets reported to the log. Other than not using an INSERT target list, you could avoid this by double-quoting the target list entries, or by not naming your plpgsql variables the same as SQL columns you are referencing in your queries. regards, tom lane