Re: function returning array

Поиск
Список
Период
Сортировка
От Joe Conway
Тема Re: function returning array
Дата
Msg-id 407EB3DF.6010304@joeconway.com
обсуждение исходный текст
Ответ на Re: function returning array  ("Dennis" <pg-user@calico-consulting.com>)
Ответы Re: function returning array
Список pgsql-sql
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



В списке pgsql-sql по дате отправления:

Предыдущее
От: Christoph Haller
Дата:
Сообщение: Re: Grant permission to all objects of user A to user B
Следующее
От: "Dennis"
Дата:
Сообщение: Re: function returning array