Re: Add items to a record variable - Mailing list pgsql-general

From Eddy D. Sanchez
Subject Re: Add items to a record variable
Date
Msg-id 4ECD017E-5FAE-4E73-B84E-514A596984C0@gmail.com
Whole thread Raw
In response to Re: Add items to a record variable  ("Postgres User" <postgres.developer@gmail.com>)
List pgsql-general
Thanks.

But I need to add fields to a defined and filled record, I don't know
if I can do it, and how can I do it.

If I have:

v_record record;

EXECUTE 'select * from table'
INTO v_record;

supposing (after query) that v_record contains just one row with 5
fields, I need to add the 6th, 7th, 8th fields, etc, etc.

Do you understand ?



On Mar 2, 2007, at 12:48 AM, Postgres User wrote:

> If you need to return a record to another function or client program,
> you can always use this sytnax:
>
> SELECT var_a::integer, var_b::integer, var_c::integer... etc
>
> where var_a, var_b, etc and local variables that hold your
> calculated values.
>
> You dont need to create a local record structure- select will do that
> for you.  The '::integer' will ensure that the values are typecast as
> integers.
>
>
> On 3/1/07, eddy sanchez <eddysan@udabol.edu.bo> wrote:
>> WEBMAIL Server: UDABOLnet, Universidad de Aquino Bolivia
>>
>> Thank you for you help
>>
>> The item is a field, I need to return a record with double
>> precision or integer
>> fields.
>>
>> I need a function that can calculate some fields (integer numbers)
>> that should
>> be added to a record inside a loop, and the result, must seems
>> like this:
>>
>> {234.00, 56434.78, 5556.89,....}
>>
>> Always, I call those functions with:
>>
>> select * from func_with_record() as (field1 integer, field2
>> integer, field3
>> integer,....)
>>
>> Do you undestand?
>>
>> Thanks a lot for your interesting.
>>
>>
>>
>> -----------------------------------
>>
>> What is the new item?  Is it a field?
>>
>> On 3/1/07, eddy sanchez <eddysan@udabol.edu.bo> wrote:
>> WEBMAIL Server: UDABOLnet, Universidad de Aquino Bolivia
>>
>>
>> Can anyone help me???
>>
>> I work with plpgsql and I need to add items to a record variable,
>> with a for
>> statement, something like this:
>>
>> declare
>>  v_rec record;
>> begin
>> for nn in (some_xpresion) loop
>>  ....
>>
>> v_rec = vrec + [new_item]; <--Here I need to add an item to record
>> variable with
>>                              each loop
>> end loop lp;
>>
>> return v_rec;
>> end;
>>
>>
>> The result should be like {it1,it2,it3,i4,....}
>>
>> Please can you help me?
>> Thanks a lot
>>
>> -------------------------------------------------
>> Este email se envio mediante el servidor WEBMAIL de UDABOLnet
>> -------------------------------------------------
>>
>> ---------------------------(end of
>> broadcast)---------------------------
>> TIP 1: if posting/reading through Usenet, please send an appropriate
>>      subscribe-nomail command to majordomo@postgresql.org so that
>> your
>>      message can get through to the mailing list cleanly
>>
>>
>>
>> -------------------------------------------------
>> Este email se envio mediante el servidor WEBMAIL de UDABOLnet
>> -------------------------------------------------
>>


pgsql-general by date:

Previous
From: "Postgres User"
Date:
Subject: Re: Add items to a record variable
Next
From: Tom Lane
Date:
Subject: Re: Fun with Cursors- how to rewind a cursor