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 9D1709FA61D for ; Wed, 5 Jul 2006 13:52:26 -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 61587-08 for ; Wed, 5 Jul 2006 13:52:22 -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 128269FA4A8 for ; Wed, 5 Jul 2006 13:52:21 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by myemma.com (Postfix) with ESMTP id 108B323CCD for ; Wed, 5 Jul 2006 12:33:45 -0500 (CDT) Received: from myemma.com ([127.0.0.1]) by localhost (velma [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 07239-08 for ; Wed, 5 Jul 2006 12:33:45 -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 32ECA23CCA for ; Wed, 5 Jul 2006 12:33:43 -0500 (CDT) Message-ID: <44ABEE3A.1030609@myemma.com> Date: Wed, 05 Jul 2006 11:52:10 -0500 From: Erik Jones User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: Postgres SQL language list Subject: Problem with array subscripts in plpgsql trigger function 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/44 X-Sequence-Number: 25618 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? -- erik jones software development emma(r)