Re: Array_append does not work with Array variables in PL/pgSQL?

From: Joe Conway <mail(at)joeconway(dot)com>
To: josh(at)agliodbs(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Array_append does not work with Array variables in PL/pgSQL?
Date: 2004-04-01 21:36:45
Message-ID: 406C8B6D.2040603@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Josh Berkus wrote:
> v_vals TEXT[];
> n_vals TEXT[];

try:
v_vals TEXT[] := ''{}'';
n_vals TEXT[] := ''{}'';

You have to initialize the array to something non-null, even if that be
an empty array (note that there is a difference). When trying to append
an element to a NULL valued array, you wind up with a NULL result. It is
similar to:

regression=# select (NULL || 'abc') is null;
?column?
----------
t
(1 row)

Joe

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2004-04-01 21:48:26 Re: Array_append does not work with Array variables in PL/pgSQL?
Previous Message Josh Berkus 2004-04-01 21:20:37 Array_append does not work with Array variables in PL/pgSQL?