From: | "Yelai, Ramkumar IN BLR STS" <ramkumar(dot)yelai(at)siemens(dot)com> |
---|---|
To: | Sergey Konoplev <sergey(dot)konoplev(at)postgresql-consulting(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-06 12:23:08 |
Message-ID: | 13D0F6C9B3073A4999E61CAAD61AE7ECC45271D26B@INBLRK77M2MSX.in002.siemens.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Thanks Sergey,
I need to know about the coloumn types for the internal calculation, hence I am unable to use this.
Since I am a new to RDBMS and Postgresql, I am understanding your concepts and thinking to use this code in my project.
Thanks & Regards,
Ramkumar.
-----Original Message-----
From: gray(dot)ru(at)gmail(dot)com [mailto:gray(dot)ru(at)gmail(dot)com] On Behalf Of Sergey Konoplev
Sent: Tuesday, September 04, 2012 3:27 PM
To: Yelai, Ramkumar IN BLR STS
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] Need to Iterate the record in plpgsql
If you do not need information about column types you can use hstore for this purpose.
[local]:5432 grayhemp(at)grayhemp=# select * from r limit 1; a | b | c
---+---+---
1 | 2 | 3
(1 row)
[local]:5432 grayhemp(at)grayhemp=# select * from each((select hstore(r) from r limit 1)); key | value
-----+-------
a | 1
b | 2
c | 3
(3 rows)
The key and value columns here of the text type.
On Fri, Aug 31, 2012 at 6:55 PM, Yelai, Ramkumar IN BLR STS <ramkumar(dot)yelai(at)siemens(dot)com> wrote:
> 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
>
>
>
>
>
--
Sergey Konoplev
a database architect, software developer at PostgreSQL-Consulting.com http://www.postgresql-consulting.com
Jabber: gray(dot)ru(at)gmail(dot)com Skype: gray-hemp Phone: +79160686204
From | Date | Subject | |
---|---|---|---|
Next Message | David Johnston | 2012-09-06 13:58:09 | Re: Need to Iterate the record in plpgsql |
Previous Message | Sergey Konoplev | 2012-09-05 09:13:57 | Re: Question regarding modelling for time series |