Re: Problem with array subscripts in plpgsql trigger function

From: "Aaron Bono" <postgresql(at)aranya(dot)com>
To: "Erik Jones" <erik(at)myemma(dot)com>
Cc: "Postgres SQL language list" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Problem with array subscripts in plpgsql trigger function
Date: 2006-07-05 17:56:31
Message-ID: bf05e51c0607051056w493c6394r7f3601ab2107d9e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 7/5/06, Erik Jones <erik(at)myemma(dot)com> wrote:
>
> Aaron Bono wrote:
> > On 7/5/06, *Erik Jones* <erik(at)myemma(dot)com <mailto:erik(at)myemma(dot)com>>
> 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

I did some digging through the documentation and cannot find any examples of
using arrays like this. Do you have to initialize the array before you use
it?

Does anyone know where to look for informaiton about using arrays in stored
procedures?

-Aaron

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Keith Worthington 2006-07-05 18:08:19 Re: "CASE" is not a variable
Previous Message Erik Jones 2006-07-05 17:42:58 Re: Problem with array subscripts in plpgsql trigger function