Re: select from composite type

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Lorusso Domenico <domenico(dot)l76(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: select from composite type
Date: 2024-02-05 00:39:15
Message-ID: 3c650059-4d07-461c-a791-3f73338a9acc@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2/4/24 14:50, Lorusso Domenico wrote:
> Hello guys,
> I'm trying to find out the equivalent behaviour of unnest, when I've got
> just a composite type.
>
> This is the statement is something like that (but more complex):
>
>  _sqlUpdate text=$$
> with s as (
> select * from ($1)
> )
> update myView as q set
> (attribute_fullname, modify_user_id)
> =(s.attribute_fullname, $2)
> where  s.product_code=q.product_code
> and s.attribute_uid=q.attribute_uid
> $$;
>
> And I use this command.
> execute _sqlUpdate using  attribute_list[_i], _modify_user_id;

Is the above in a plpgsql function?

>
> attribute_list is  an array of composite type (with 20 fields).

I am trying to wrap my head around "array of composite type". Please
provide an example.

>
> If I use the unnest with the entire array the sql works, but I can't
> find a way to treat the single record as a row of  a table.
>
>
> Any suggestions?
>
> Bye and thanks'
>
> Domenico

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2024-02-05 00:48:19 Re: select from composite type
Previous Message Ron Johnson 2024-02-04 23:40:19 Re: Question on partitioning