Re: arrays in pl/pgsql

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: arrays in pl/pgsql
Дата
Msg-id 18350.1071546938@sss.pgh.pa.us
обсуждение исходный текст
Ответ на arrays in pl/pgsql  (Michael Shapiro <mshapiro@ncsa.uiuc.edu>)
Список pgsql-sql
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


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

Предыдущее
От: Michael Shapiro
Дата:
Сообщение: arrays in pl/pgsql
Следующее
От: Olivier Hubaut
Дата:
Сообщение: Re: dump and schema