Re: Need to Iterate the record in plpgsql

From: "Yelai, Ramkumar IN BLR STS" <ramkumar(dot)yelai(at)siemens(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Need to Iterate the record in plpgsql
Date: 2012-09-04 09:31:10
Message-ID: 13D0F6C9B3073A4999E61CAAD61AE7ECC4526E257D@INBLRK77M2MSX.in002.siemens.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi Pavel,

Thanks for the links, but due to the project schedules I have changed procedure logic to use array in iteration instead of records.

However, the trigger logic is really good but it seems slow as you said. The blog is really good source to understand plpgsql in better way.

Thanks & Regards,
Ramkumar

-----Original Message-----
From: Pavel Stehule [mailto:pavel(dot)stehule(at)gmail(dot)com]
Sent: Tuesday, September 04, 2012 11:52 AM
To: Yelai, Ramkumar IN BLR STS
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] Need to Iterate the record in plpgsql

Hello

http://okbob.blogspot.cz/2010/12/iteration-over-record-in-plpgsql.html
http://postgres.cz/wiki/PostgreSQL_SQL_Tricks#Iteration_over_RECORD_variable_inside_trigger

Regards

Pavel Stehule

2012/8/31 Yelai, Ramkumar IN BLR STS <ramkumar(dot)yelai(at)siemens(dot)com>:
> Hi All,
>
> I am facing a issue in Iterating the RECORD.
>
> The problem is, I would like to iterate the RECORD without using sql
> query, but as per the syntax I have to use query as shown below.
>
> FOR target IN query LOOP
> statements
> END LOOP [ label ];
>
> In my procedure, I have stored one of the procedure output as record,
> which I am later using in another iteration. Below is the example
>
>
> CREATE OR REPLACE FUNCTION test2()
>
> Rec1 RECORD;
> Rec2 RECORD;
> Rec3 RECORD;
>
> SELECT * INTO REC1 FROM test();
>
> FOR REC2 IN ( select * from test3())
> LOOP
> FOR REC3 IN REC2 --- this syntax does not allowed by Postgresql
> LOOP
>
> END LOOP
> END LOOP
>
> As per the example, How can I iterate pre stored record.
>
> Please let me know if you have any suggestions.
>
> Thanks & Regards,
> Ramkumar
>
>
>
>
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Sergey Konoplev 2012-09-04 09:56:49 Re: Need to Iterate the record in plpgsql
Previous Message Pavel Stehule 2012-09-04 06:22:27 Re: Need to Iterate the record in plpgsql