X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 0CF919FA61D for ; Wed, 5 Jul 2006 14:43:09 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 39093-09 for ; Wed, 5 Jul 2006 14:43:04 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from myemma.com (db1.e2ma.net [66.179.147.163]) by postgresql.org (Postfix) with ESMTP id E23E99FA4A8 for ; Wed, 5 Jul 2006 14:43:03 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by myemma.com (Postfix) with ESMTP id 2B4D123CCD; Wed, 5 Jul 2006 13:24:28 -0500 (CDT) Received: from myemma.com ([127.0.0.1]) by localhost (velma [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 11607-04; Wed, 5 Jul 2006 13:24:28 -0500 (CDT) Received: from [192.168.1.68] (65.107.156.170.ptr.us.xo.net [65.107.156.170]) by myemma.com (Postfix) with ESMTP id D3DC423CCA; Wed, 5 Jul 2006 13:24:27 -0500 (CDT) Message-ID: <44ABFA22.9060006@myemma.com> Date: Wed, 05 Jul 2006 12:42:58 -0500 From: Erik Jones User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: Aaron Bono Cc: Postgres SQL language list Subject: Re: Problem with array subscripts in plpgsql trigger function References: <44ABEE3A.1030609@myemma.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at myemma.com X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/46 X-Sequence-Number: 25620 Aaron Bono wrote: > On 7/5/06, *Erik Jones* > wrote: > > Ok, I have a trigger set up on the following (stripped down) table: > > CREATE TABLE members ( > member_id bigint, > member_status_id smallint, > member_is_deleted boolean > ); > > Here's a shortened version of the trigger function: > > CREATE OR REPLACE FUNCTION update_member() RETURNS TRIGGER AS $um$ > DECLARE > status_deltas integer[]; > BEGIN > IF(NEW.member_status_id != OLD.member_status_id AND > NEW.member_is_deleted IS NOT TRUE) THEN > status_deltas[NEW.member_status_id] := 1; > status_deltas[OLD.member_status_id] := -1; > END IF; > /*and after a couple more such conditional assignments I use the > values in status_deltas to update another table holding status > totals here*/ > END; > $um$ LANGUAGE plpgsql; > > on the two lines that access set array values I'm getting the > following > error: > > ERROR: invalid array subscripts > > What gives? > > > > What values are being used for member_status_id? > 1, 2, and 3 -- erik jones software development emma(r)