[prev in list] [next in list] [prev in thread] [next in thread]
List: postgresql-sql
Subject: [SQL] Need to Iterate the record in plpgsql
From: "Yelai, Ramkumar IN BLR STS" <ramkumar.yelai () siemens ! com>
Date: 2012-08-31 15:07:50
Message-ID: 13D0F6C9B3073A4999E61CAAD61AE7ECC45265BA99 () INBLRK77M2MSX ! in002 ! siemens ! net
[Download RAW message or body]
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
[Attachment #3 (text/html)]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 \
2px solid; } --></style> </head>
<body>
<font face="Verdana, sans-serif" size="2">
<div>Hi All,</div>
<div> </div>
<div>I am facing a issue in Iterating the RECORD.</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>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.</div> <div> </div>
<div>FOR target IN query LOOP</div>
<div> statements</div>
<div>END LOOP [ label ];</div>
<div><font face="Courier New, monospace"> </font></div>
<div>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</div> <div><font face="Courier \
New, monospace"> </font></div> <div><font face="Courier New, \
monospace"> </font></div> <div>CREATE OR REPLACE FUNCTION test2()</div>
<div><font face="Courier New, monospace"> </font></div>
<div>Rec1 RECORD;</div>
<div>Rec2 RECORD;</div>
<div>Rec3 RECORD;</div>
<div><font face="Courier New, monospace"> </font></div>
<div>SELECT * INTO REC1 FROM test();</div>
<div> </div>
<div>FOR REC2 IN ( select * from test3())</div>
<div>LOOP</div>
<div> FOR REC3 IN REC2 --- this syntax does \
not allowed by Postgresql</div> <div><font face="Courier New, \
monospace"> <font face="Verdana, \
sans-serif">LOOP</font></font></div> <div> </div>
<div> END LOOP</div>
<div>END LOOP</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>As per the example, How can I iterate pre stored record.</div>
<div> </div>
<div>Please let me know if you have any suggestions.</div>
<div><br>
Thanks & Regards,</div>
<div>Ramkumar</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
</font>
</body>
</html>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic