From: Joe Conway <mail@joeconway.com>
To: Dennis <pg-user@calico-consulting.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: postgres SQL <pgsql-sql@postgresql.org>
Subject: Re: function returning array
Date: Thu, 15 Apr 2004 09:10:07 -0700
Message-ID: <407EB3DF.6010304@joeconway.com> (raw)
In-Reply-To: <courier.407E7D02.00006AB1@wolverine.lercnetworks.com>
References: <courier.407C6CB0.00005135@wolverine.lercnetworks.com>
<29772.1081913447@sss.pgh.pa.us>
<courier.407E7D02.00006AB1@wolverine.lercnetworks.com>
Dennis wrote:
> pg 7.4.1
>
> I should have listed the source for the function. Here is a simplified
> parseString function and the foo that calls it.
>
> dennis=# create or replace function parseString (varchar, varchar)
> dennis-# RETURNS varchar[] AS '
> dennis'# DECLARE
> dennis'# pParsed varchar[];
Make that last line:
pParsed varchar[] := ''{}'';
That initializes pParsed to an *empty* array. Otherwise pParsed is NULL,
and when you attempt to extend a NULL array, e.g. "pParsed[1] =
''blah''" you still get NULL. It is similar to this:
regression=# select NULL || 'blah';
?column?
----------
(1 row)
HTH,
Joe
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: mail@joeconway.com, pg-user@calico-consulting.com, tgl@sss.pgh.pa.us
Subject: Re: function returning array
In-Reply-To: <407EB3DF.6010304@joeconway.com>
* 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