Re: Equivalent syntax of PL/SQL using array in PL/pgSQL - Mailing list pgsql-general

From Elliot
Subject Re: Equivalent syntax of PL/SQL using array in PL/pgSQL
Date
Msg-id 5284EE7B.3060109@gmail.com
Whole thread Raw
In response to Re: Equivalent syntax of PL/SQL using array in PL/pgSQL  (Dang Minh Huong <kakalot49@gmail.com>)
Responses Re: Equivalent syntax of PL/SQL using array in PL/pgSQL
List pgsql-general
On 2013-11-14 10:32, Dang Minh Huong wrote:
> Hi,
>
> 2013/11/15 0:20、Elliot <yields.falsehood@gmail.com> のメッセージ:
>
>>> On 2013-11-14 10:13, Dang Minh Huong wrote:
>>> Hi all,
>>>
>>> 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;
>>> ------
>>>
>>> typ is type which was created by command below.
>>>
>>> Create type typ as(
>>> t1 interger,
>>> t2 text);
>>>
>>> I am migrating data from Oracle to PostgreSQL and encounter this issue.
>>>
>>> Thanks,
>>> Huong,
>> If typ is the type and rec is the variable, do you mean to access rec[1]?
> Sorry for this miss.
> Yes, typ is the type and rec is the variable.
> I only want to assign a value to rec[1].t1.
>
> Thanks,
> Huong,

I can't recall a source on this but I'm not sure you can assign to
composite types' members in plpgsql (unlike in straight sql where update
set rec.t1 := 1 is valid). You can build the entire record at once like
"rec[1] := (1, null)::typ;".



pgsql-general by date:

Previous
From: Dang Minh Huong
Date:
Subject: Re: Equivalent syntax of PL/SQL using array in PL/pgSQL
Next
From: David Johnston
Date:
Subject: Re: Equivalent syntax of PL/SQL using array in PL/pgSQL