 




<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Using cursor in SQLRPGLE</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/using-cursor-in-sqlrpgle/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/using-cursor-in-sqlrpgle/</link>
	<description></description>
	<lastBuildDate>Mon, 20 May 2013 05:26:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: philpl1jb</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/using-cursor-in-sqlrpgle/#comment-112106</link>
		<dc:creator>philpl1jb</dc:creator>
		<pubDate>Wed, 10 Oct 2012 13:22:37 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/?p=264469#comment-112106</guid>
		<description><![CDATA[Can i use single cursor for multiple SQL statements? ex:&#160; declare c1 cursor for select * from ....... also declare c1 cursor for select * from xxx&#160;&#160; 
No.&#160; I&#039;ve forgotten if it was the precompiler or compiler that rejected this regardless of the close cursor commands.&#160; 
&#160;
But as BigCat pointed out you can use a single dynamic SQL command multiple times with different SQL statments, just remember to close the cursor after use.&#160; 
Phil]]></description>
		<content:encoded><![CDATA[<p>Can i use single cursor for multiple SQL statements? ex:&nbsp; declare c1 cursor for select * from &#8230;&#8230;. also declare c1 cursor for select * from xxx&nbsp;&nbsp;<br />
No.&nbsp; I&#8217;ve forgotten if it was the precompiler or compiler that rejected this regardless of the close cursor commands.&nbsp;<br />
&nbsp;<br />
But as BigCat pointed out you can use a single dynamic SQL command multiple times with different SQL statments, just remember to close the cursor after use.&nbsp;<br />
Phil</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BigKat</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/using-cursor-in-sqlrpgle/#comment-112103</link>
		<dc:creator>BigKat</dc:creator>
		<pubDate>Wed, 10 Oct 2012 12:37:02 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/?p=264469#comment-112103</guid>
		<description><![CDATA[exec sql prepare sql1 from :stmsql1;
exec sql declare csr1 cursor for sql1;
exec sql open csr1 using :fltvnd, :fltvnd, :fltdsc, :fltdsc;
exec sql fetch csr1 into :fpitmmas;
exec sql close csr1;]]></description>
		<content:encoded><![CDATA[<p>exec sql prepare sql1 from :stmsql1;<br />
exec sql declare csr1 cursor for sql1;<br />
exec sql open csr1 using :fltvnd, :fltvnd, :fltdsc, :fltdsc;<br />
exec sql fetch csr1 into :fpitmmas;<br />
exec sql close csr1;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BigKat</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/using-cursor-in-sqlrpgle/#comment-112102</link>
		<dc:creator>BigKat</dc:creator>
		<pubDate>Wed, 10 Oct 2012 12:35:04 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/?p=264469#comment-112102</guid>
		<description><![CDATA[yes, you can build a select statement in a variable, then 
exec sql prepare sql1 from :stmsql1;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; exec sql declare csr1 cursor for sql1;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; exec sql open csr1 using :fltvnd, :fltvnd, :fltdsc, :fltdsc; exec sql fetch csr1 into :fpitmmas;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; exec sql close csr1;&#160;
then re-build a new select and repeat as desired]]></description>
		<content:encoded><![CDATA[<p>yes, you can build a select statement in a variable, then<br />
exec sql prepare sql1 from :stmsql1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exec sql declare csr1 cursor for sql1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exec sql open csr1 using :fltvnd, :fltvnd, :fltdsc, :fltdsc; exec sql fetch csr1 into :fpitmmas;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exec sql close csr1;&nbsp;<br />
then re-build a new select and repeat as desired</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TomLiotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/using-cursor-in-sqlrpgle/#comment-112100</link>
		<dc:creator>TomLiotta</dc:creator>
		<pubDate>Wed, 10 Oct 2012 12:12:18 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/?p=264469#comment-112100</guid>
		<description><![CDATA[Sorry. The four lines of code ran together.
&#160;
sql_stmt = &#039;SELECT * FROM ...&#039;
exec sql prepare stmt from :sql_stmt;
exec sql declare C1 cursor for stmt;
exec sql open C1;
&#160;
Those might or might not come across as readable.
&#160;
Tom]]></description>
		<content:encoded><![CDATA[<p>Sorry. The four lines of code ran together.<br />
&nbsp;<br />
sql_stmt = &#8216;SELECT * FROM &#8230;&#8217;<br />
exec sql prepare stmt from :sql_stmt;<br />
exec sql declare C1 cursor for stmt;<br />
exec sql open C1;<br />
&nbsp;<br />
Those might or might not come across as readable.<br />
&nbsp;<br />
Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TomLiotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/using-cursor-in-sqlrpgle/#comment-112099</link>
		<dc:creator>TomLiotta</dc:creator>
		<pubDate>Wed, 10 Oct 2012 12:08:51 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/?p=264469#comment-112099</guid>
		<description><![CDATA[I&#039;ve never tried. I suppose that as long as one cursor was closed before you opened the other, and the two declares themselves were on different code paths, it could be done.
&#160;
But it&#039;s hard to think of a reason to do it since there&#039;s a far easier alternative:
&#160;
&lt;BLOCKQUOTE&gt;&lt;CODE&gt;sql_stmt = &#039;SELECT * FROM ...&#039;exec sql prepare stmt from :sql_stmt;exec sql declare C1 cursor for stmt;exec sql open C1;&lt;/CODE&gt;&lt;/BLOCKQUOTE&gt;
&#160;
(That code looks perfect in the editor, but I suspect it will look a mess when I submit it.) Multiple assignments can be made for sql_stmt to use whatever SELECT statement you want. (Of course, you should never use &quot;*&quot; for the column list; but that&#039;s not what you&#039;re asking about.)
&#160;
Tom]]></description>
		<content:encoded><![CDATA[<p>I&#8217;ve never tried. I suppose that as long as one cursor was closed before you opened the other, and the two declares themselves were on different code paths, it could be done.<br />
&nbsp;<br />
But it&#8217;s hard to think of a reason to do it since there&#8217;s a far easier alternative:<br />
&nbsp;</p>
<blockquote><p><code>sql_stmt = &#8216;SELECT * FROM &#8230;&#8217;exec sql prepare stmt from :sql_stmt;exec sql declare C1 cursor for stmt;exec sql open C1;</code></p></blockquote>
<p>&nbsp;<br />
(That code looks perfect in the editor, but I suspect it will look a mess when I submit it.) Multiple assignments can be made for sql_stmt to use whatever SELECT statement you want. (Of course, you should never use &#8220;*&#8221; for the column list; but that&#8217;s not what you&#8217;re asking about.)<br />
&nbsp;<br />
Tom</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 3/10 queries in 0.041 seconds using memcached
Object Caching 323/329 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-20 08:44:53 -->