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

From Postgres User
Subject Re: Add items to a record variable
Date
Msg-id b88c3460703012048t38188c7fxb0722951f3b7168c@mail.gmail.com
Whole thread Raw
In response to Add items to a record variable  (eddy sanchez <eddysan@udabol.edu.bo>)
Responses Re: Add items to a record variable  ("Eddy D. Sanchez" <eddy.sanchez@gmail.com>)
List pgsql-general
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: Fun with Cursors- how to rewind a cursor
Next
From: "Eddy D. Sanchez"
Date:
Subject: Re: Add items to a record variable