Skip site navigation (1) Skip section navigation (2)

Acccessing individual array elements form plpgsql

From: "Celia McInnis" <celia(at)drmath(dot)ca>
To: pgsql-novice(at)postgresql(dot)org
Subject: Acccessing individual array elements form plpgsql
Date: 2005-03-11 22:41:10
Message-ID: 20050311223953.M46258@drmath.ca (view raw or flat)
Thread:
Lists: pgsql-novice
Hi:

plpgsql allows me to define an array:

 direction TEXT[2]:=array['out','in'];

and I can print out the whole array via:

 RAISE NOTICE 'direction=%',direction;

getting:

 direction={in,out}

but how do I access members of this array individually??? I'd love it if
direction[1] would pull out the 2nd or 1st element so that I could use it in
the selects which my procedure is forming, but I get syntax errors when I try
to reference the array element in such a way. For example:

 RAISE NOTICE '%',direction[1];

gives:

 ERROR:  syntax error at or near "[" at character ####
 LINE ##: RAISE NOTICE '%',direction[1];
                                     ^
Thanks for any help which you can give. I am running postgresql 8.0.1.

Celia McInnis

--
Open WebMail Project (http://openwebmail.org)


Responses

pgsql-novice by date

Next:From: Tom LaneDate: 2005-03-11 22:46:49
Subject: Re: Acccessing individual array elements form plpgsql
Previous:From: Celia McInnisDate: 2005-03-11 22:31:08
Subject: Acessing array element from plpgsql

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group