pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Shapiro <mshapiro@ncsa.uiuc.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: arrays in pl/pgsql
Date: Mon, 15 Dec 2003 22:55:38 -0500
Message-ID: <18350.1071546938@sss.pgh.pa.us> (raw)
In-Reply-To: <200312160339.hBG3d0q31028@osage.ncsa.uiuc.edu>
References: <200312160339.hBG3d0q31028@osage.ncsa.uiuc.edu>

Michael Shapiro <mshapiro@ncsa.uiuc.edu> writes:
> I have tried the following (which doesn't work)
> 	dn[1] := \'a\';
> The parser doesn't like the [ that follows dn.

I believe Joe Conway fixed this in 7.4.  Note that you also need to
initialize the array to something, because assigning to an element
of a NULL array still yields a NULL array result.  For example:

regression=# create or replace function foo() returns text as '
regression'# declare dn text[] := \'{}\';
regression'# begin
regression'#   dn[1] := \'a\';
regression'#   return dn[1];
regression'# end' language plpgsql;
CREATE FUNCTION
regression=# select foo();
 foo
-----
 a
(1 row)

			regards, tom lane



view thread (2+ messages)

Message-ID: <18350.1071546938@sss.pgh.pa.us>
Permalink:  ../18350.1071546938@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/18350.1071546938@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mshapiro@ncsa.uiuc.edu
  Subject: Re: arrays in pl/pgsql
  In-Reply-To: <18350.1071546938@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox