Re: Equivalent syntax of PL/SQL using array in PL/pgSQL

Поиск
Список
Период
Сортировка
От Dang Minh Huong
Тема Re: Equivalent syntax of PL/SQL using array in PL/pgSQL
Дата
Msg-id 13A78EBB-7B21-4741-A2E3-94B38F0C6F02@gmail.com
обсуждение исходный текст
Ответ на Re: Equivalent syntax of PL/SQL using array in PL/pgSQL  (Sergey Konoplev <gray.ru@gmail.com>)
Список pgsql-general
Thank you all for your support.

2013/11/15 3:40、Sergey Konoplev <gray.ru@gmail.com> のメッセージ:

>> On Thu, Nov 14, 2013 at 7:13 AM, Dang Minh Huong <kakalot49@gmail.com> wrote:
>> I am using PostgreSQL 9.1 and get a syntax error with the following PL/pgSQL clause.
>> Is there any equivalent syntax in PL/pgSQL to solve it.
>>
>> ------
>> rec typ[];
>> (typ[1]).t1 := 1;
>> ------
>
> You can easily make different tricks with records using the hstore
> module [1]. Just like this:
>
> [local]:5432 grayhemp@grayhemp=# \d a
>       Table "public.a"
> Column |  Type   | Modifiers
> --------+---------+-----------
> id     | integer | not null
> n      | name    |
>
> [local]:5432 grayhemp@grayhemp=# do $$
> declare rec a[];
> begin
>    rec[1] := (1, 'a')::a;
>    rec[2] := (2, 'b')::a;
>    rec[1] := rec[1] #= (hstore('id', 3::text) || hstore('n', null));
>    raise info '% %', rec[1].id, rec[1].n;
> end $$;
> INFO:  3 <NULL>
> DO
>
> [1] http://www.postgresql.org/docs/9.3/static/hstore.html
>
Thanks, i will try it.

> --
> Kind regards,
> Sergey Konoplev
> PostgreSQL Consultant and DBA
>
> http://www.linkedin.com/in/grayhemp
> +1 (415) 867-9984, +7 (901) 903-0499, +7 (988) 888-1979
> gray.ru@gmail.com

Thanks,
Huong,

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

Предыдущее
От: Philippe Girolami
Дата:
Сообщение: Push predicate down in view containing window function
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Push predicate down in view containing window function