 




<?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 SQL in RPG</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/using-sql-in-rpg/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/using-sql-in-rpg/</link>
	<description></description>
	<lastBuildDate>Mon, 20 May 2013 15:01:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: TomLiotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/using-sql-in-rpg/#comment-111349</link>
		<dc:creator>TomLiotta</dc:creator>
		<pubDate>Fri, 21 Sep 2012 21:13:00 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/using-sql-in-rpg/#comment-111349</guid>
		<description><![CDATA[&lt;EM&gt;i&#160;have not heard of Query Manager.&lt;/EM&gt;
&#160;
First, it&#039;s a very good idea to learn embedded SQL in a programming language such as RPG (ILE version is best, but any embedded SQL experience is better than none.)
&#160;
In the long run, though, the understanding that &quot;embedded&quot; SQL is best used when there is a need for a programming language to manipulate the values. Simple transfers of values from one file to another, or anything that can be done cleanly by SQL itself, aren&#039;t well suited for it.
&#160;
As for Query Manager, your system might have the full user interface installed or it might only have the run-time support. Either way, printing your queries is easy. To determine which options are available to you, try to run the STRQM command on a command line. If you are shown the Query Manager menu, you have the full user interface.
&#160;
Post your result&#160;back here for more info.
&#160;
Tom]]></description>
		<content:encoded><![CDATA[<p><em>i&nbsp;have not heard of Query Manager.</em><br />
&nbsp;<br />
First, it&#8217;s a very good idea to learn embedded SQL in a programming language such as RPG (ILE version is best, but any embedded SQL experience is better than none.)<br />
&nbsp;<br />
In the long run, though, the understanding that &#8220;embedded&#8221; SQL is best used when there is a need for a programming language to manipulate the values. Simple transfers of values from one file to another, or anything that can be done cleanly by SQL itself, aren&#8217;t well suited for it.<br />
&nbsp;<br />
As for Query Manager, your system might have the full user interface installed or it might only have the run-time support. Either way, printing your queries is easy. To determine which options are available to you, try to run the STRQM command on a command line. If you are shown the Query Manager menu, you have the full user interface.<br />
&nbsp;<br />
Post your result&nbsp;back here for more info.<br />
&nbsp;<br />
Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TomLiotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/using-sql-in-rpg/#comment-111339</link>
		<dc:creator>TomLiotta</dc:creator>
		<pubDate>Fri, 21 Sep 2012 18:50:13 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/using-sql-in-rpg/#comment-111339</guid>
		<description><![CDATA[First, simplify your two SELECT statements:
&#160;
&lt;BLOCKQUOTE&gt;
&lt;CODE&gt;SELECT RNSREGN, COUNT(RNSINVN), SUM(RNSQTY), SUM(RNSTOT$) FROM WFILES/RNSORDP WHERE RNSREGN &gt; 0 GROUP BY RNSREGN &lt;/CODE&gt;
&lt;CODE&gt;SELECT BOHREGN, COUNT(BOHINVN), SUM(BOHQTY), SUM(BOHDTTOT) FROM WFILES/BOHEDR WHERE BOHREGN &gt; 0 GROUP BY BOHREGN &lt;/CODE&gt;&lt;/BLOCKQUOTE&gt;
&#160;
There will be no reason to rename your columns because that will happen when SQL places the values in the RPG program variables that you will define.
&#160;
Also, you probably should change your database so that you don&#039;t have a field named &quot;RNSTOT$&quot;, but you might not have any choice for that. You don&#039;t want characters such as &quot;$&quot; as part of a name. It can work, but it can be a problem someday. The sooner it is fixed, the better.
&#160;
And actually all of those names should be changed. They are all too short to be very useful. Again, they will work; but better names will be useful in the future.
&#160;
It&#039;s not clear why you would want to do this in RPG. If you are only SELECTing rows and printing them, it would be far better to do it with Query Manager. Usually you would put SQL statements into a program only if you want the program to process the values. But you aren&#039;t doing any processing. You&#039;re just copying the values from the table to a printer.
&#160;
Also, you didn&#039;t say if you must use OPM RPG or ILE RPG. The names from your tables look like they are intended for the old OPM RPG. If that is what you need, you should tell us.
&#160;
Other than that, Phil&#039;s comments are right. Look at examples that are already provided in the Information Center first. Then show us what you have written for a program. We&#039;ll help get you past any errors.
&#160;
However, we don&#039;t write programs for you.
&#160;
Tom]]></description>
		<content:encoded><![CDATA[<p>First, simplify your two SELECT statements:<br />
&nbsp;</p>
<blockquote><p>
<code>SELECT RNSREGN, COUNT(RNSINVN), SUM(RNSQTY), SUM(RNSTOT$) FROM WFILES/RNSORDP WHERE RNSREGN &gt; 0 GROUP BY RNSREGN </code><br />
<code>SELECT BOHREGN, COUNT(BOHINVN), SUM(BOHQTY), SUM(BOHDTTOT) FROM WFILES/BOHEDR WHERE BOHREGN &gt; 0 GROUP BY BOHREGN </code></p></blockquote>
<p>&nbsp;<br />
There will be no reason to rename your columns because that will happen when SQL places the values in the RPG program variables that you will define.<br />
&nbsp;<br />
Also, you probably should change your database so that you don&#8217;t have a field named &#8220;RNSTOT$&#8221;, but you might not have any choice for that. You don&#8217;t want characters such as &#8220;$&#8221; as part of a name. It can work, but it can be a problem someday. The sooner it is fixed, the better.<br />
&nbsp;<br />
And actually all of those names should be changed. They are all too short to be very useful. Again, they will work; but better names will be useful in the future.<br />
&nbsp;<br />
It&#8217;s not clear why you would want to do this in RPG. If you are only SELECTing rows and printing them, it would be far better to do it with Query Manager. Usually you would put SQL statements into a program only if you want the program to process the values. But you aren&#8217;t doing any processing. You&#8217;re just copying the values from the table to a printer.<br />
&nbsp;<br />
Also, you didn&#8217;t say if you must use OPM RPG or ILE RPG. The names from your tables look like they are intended for the old OPM RPG. If that is what you need, you should tell us.<br />
&nbsp;<br />
Other than that, Phil&#8217;s comments are right. Look at examples that are already provided in the Information Center first. Then show us what you have written for a program. We&#8217;ll help get you past any errors.<br />
&nbsp;<br />
However, we don&#8217;t write programs for you.<br />
&nbsp;<br />
Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: philpl1jb</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/using-sql-in-rpg/#comment-111331</link>
		<dc:creator>philpl1jb</dc:creator>
		<pubDate>Fri, 21 Sep 2012 16:14:01 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/using-sql-in-rpg/#comment-111331</guid>
		<description><![CDATA[I wonder what happened to my first answer....&#160; It said that since these each can return multiple rows they each require a cursor,&#160;the basic process is:&#160; - Declare cursor- Open cursor- fetch a row at a time into host variables or host data structure until no more rows exist.&#160; here is an example&#160; &lt;a href=&quot;http://www.itjungle.com/fhg/fhg051309-story02.html&quot; rel=&quot;nofollow&quot;&gt;http://www.itjungle.com/fhg/fhg051309-story02.html&lt;/a&gt;]]></description>
		<content:encoded><![CDATA[<p>I wonder what happened to my first answer&#8230;.&nbsp; It said that since these each can return multiple rows they each require a cursor,&nbsp;the basic process is:&nbsp; &#8211; Declare cursor- Open cursor- fetch a row at a time into host variables or host data structure until no more rows exist.&nbsp; here is an example&nbsp; <a href="http://www.itjungle.com/fhg/fhg051309-story02.html" rel="nofollow">http://www.itjungle.com/fhg/fhg051309-story02.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: philpl1jb</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/using-sql-in-rpg/#comment-111330</link>
		<dc:creator>philpl1jb</dc:creator>
		<pubDate>Fri, 21 Sep 2012 15:54:42 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/using-sql-in-rpg/#comment-111330</guid>
		<description><![CDATA[Each of these SQL&#039;s are likely to select multiple rows.&#160;&#160;For each of these&#160;you will need to:&#160; Declare&#160;a cursor Open the cursorFetch rows from the cursor into the host fields&#160; Here is an example:&#160; &lt;a href=&quot;http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Fsqlp%2Frbafycursorexamp.htm&quot; rel=&quot;nofollow&quot;&gt;http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Fsqlp%2Frbafycursorexamp.htm&lt;/a&gt;&#160; and another example:&#160; &lt;a href=&quot;http://www.itjungle.com/fhg/fhg051309-story02.html&quot; rel=&quot;nofollow&quot;&gt;http://www.itjungle.com/fhg/fhg051309-story02.html&lt;/a&gt;&#160; &#160;]]></description>
		<content:encoded><![CDATA[<p>Each of these SQL&#8217;s are likely to select multiple rows.&nbsp;&nbsp;For each of these&nbsp;you will need to:&nbsp; Declare&nbsp;a cursor Open the cursorFetch rows from the cursor into the host fields&nbsp; Here is an example:&nbsp; <a href="http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Fsqlp%2Frbafycursorexamp.htm" rel="nofollow">http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Fsqlp%2Frbafycursorexamp.htm</a>&nbsp; and another example:&nbsp; <a href="http://www.itjungle.com/fhg/fhg051309-story02.html" rel="nofollow">http://www.itjungle.com/fhg/fhg051309-story02.html</a>&nbsp; &nbsp;</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.040 seconds using memcached
Object Caching 309/315 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-20 15:15:25 -->