From: | aditya desai <admad123(at)gmail(dot)com> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org> |
Subject: | Re: How to assign variable in array value inside function proc. |
Date: | 2021-10-30 17:43:52 |
Message-ID: | CAN0SRDHyjfakDxrYeLXzyBTFc-FBc0OYiynBzcigGqgMrxQETQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Thanks David!! This helped.
On Thursday, October 28, 2021, David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
wrote:
> On Thursday, October 28, 2021, aditya desai <admad123(at)gmail(dot)com> wrote:
>>
>>
>> How to assign variable values in v_message in Function 2 and pass to
>> function 1. How can I do this? Instead of COLUMN1,OLDVALUE1,NEWVALUE1 it
>> should take variables assigned.
>>
>>
> In pure sql I would do:
>
> ARRAY[col1, col2, col3]::type[]
>
> To create an array using column references as inputs instead of literals.
>
> Likewise, for a composite type:
>
> (co1, col2, col3)::type
>
> You will probably need to use those constructs as fragments in your
> pl/pgsql code to build up the array of composites from variables/columns as
> opposed to trying to write a text literal.
>
> If you want to write a literal, though, you may find the format() function
> to be helpful (and a sight easier to read, and generally safer, than string
> concatenation, which would be your option of last resort.
>
> David J.
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | aditya desai | 2021-11-01 16:20:11 | Re: How to assign variable in array value inside function proc. |
Previous Message | David G. Johnston | 2021-10-28 18:05:43 | Re: How to assign variable in array value inside function proc. |