 




<?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: AS/400:- I need to build a query to select records, to be displayed in subfile</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/as400-i-need-to-build-a-query-to-select-records-to-be-displayed-in-subfile/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/as400-i-need-to-build-a-query-to-select-records-to-be-displayed-in-subfile/</link>
	<description></description>
	<lastBuildDate>Sat, 25 May 2013 23:02:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: gilly400</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/as400-i-need-to-build-a-query-to-select-records-to-be-displayed-in-subfile/#comment-53363</link>
		<dc:creator>gilly400</dc:creator>
		<pubDate>Thu, 22 May 2008 15:59:54 +0000</pubDate>
		<guid isPermaLink="false">#comment-53363</guid>
		<description><![CDATA[Hi,

I would probably also opt for the embedded SQL approach, you could define a cursor with a select something like this:-

&lt;b&gt;&lt;pre&gt;SELECT * FROM mytable
WHERE
(FaxreferenceNumber &gt;= :FromFaxreferenceNumber OR :FromFaxreferenceNumber = &#039; &#039;) AND
(FaxreferenceNumber &lt;= :ToFaxreferenceNumber OR :ToFaxreferenceNumber = &#039; &#039;) AND
(OrderDate &gt;= :FromOrderDate OR :FromOrderDate = 0) AND
(OrderDate &lt;= :ToOrderDate OR :ToOrderDate = 0) AND&lt;/pre&gt;&lt;/b&gt;
etc.

Regards,

Martin Gilbert.]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I would probably also opt for the embedded SQL approach, you could define a cursor with a select something like this:-</p>
<p><b>
<pre>SELECT * FROM mytable
WHERE
(FaxreferenceNumber &gt;= :FromFaxreferenceNumber OR :FromFaxreferenceNumber = ' ') AND
(FaxreferenceNumber &lt;= :ToFaxreferenceNumber OR :ToFaxreferenceNumber = ' ') AND
(OrderDate &gt;= :FromOrderDate OR :FromOrderDate = 0) AND
(OrderDate &lt;= :ToOrderDate OR :ToOrderDate = 0) AND</pre>
<p></b><br />
etc.</p>
<p>Regards,</p>
<p>Martin Gilbert.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sloopy</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/as400-i-need-to-build-a-query-to-select-records-to-be-displayed-in-subfile/#comment-53358</link>
		<dc:creator>sloopy</dc:creator>
		<pubDate>Thu, 22 May 2008 14:42:48 +0000</pubDate>
		<guid isPermaLink="false">#comment-53358</guid>
		<description><![CDATA[I would do it Reddy&#039;s way, but using embedded SQL, which is far faster than QMQRY or OPNQRYF and works with fetches within the RPG loop that fills the subfile.

We do, in fact, do that sort of thing a lot here.

Sloopy]]></description>
		<content:encoded><![CDATA[<p>I would do it Reddy&#8217;s way, but using embedded SQL, which is far faster than QMQRY or OPNQRYF and works with fetches within the RPG loop that fills the subfile.</p>
<p>We do, in fact, do that sort of thing a lot here.</p>
<p>Sloopy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: narasimhareddy</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/as400-i-need-to-build-a-query-to-select-records-to-be-displayed-in-subfile/#comment-53349</link>
		<dc:creator>narasimhareddy</dc:creator>
		<pubDate>Thu, 22 May 2008 11:15:45 +0000</pubDate>
		<guid isPermaLink="false">#comment-53349</guid>
		<description><![CDATA[It can be done using only one query thru QMQRY

Write Query with Varibles for all conditions.

In program before executing Load the values with values entered, If no value is entered for any field, then you can store Lowest Values for the from field, and highest possible values into To field.

Ex: If it is Numeric field with length 5 then 00000 into from value &amp;  99999 into TO field.
   If selection values are entered, then the value entered can be moved into FROm &amp; TO fields.

I hope this helps.

Reddy]]></description>
		<content:encoded><![CDATA[<p>It can be done using only one query thru QMQRY</p>
<p>Write Query with Varibles for all conditions.</p>
<p>In program before executing Load the values with values entered, If no value is entered for any field, then you can store Lowest Values for the from field, and highest possible values into To field.</p>
<p>Ex: If it is Numeric field with length 5 then 00000 into from value &amp;  99999 into TO field.<br />
   If selection values are entered, then the value entered can be moved into FROm &amp; TO fields.</p>
<p>I hope this helps.</p>
<p>Reddy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mcl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/as400-i-need-to-build-a-query-to-select-records-to-be-displayed-in-subfile/#comment-53330</link>
		<dc:creator>mcl</dc:creator>
		<pubDate>Wed, 21 May 2008 15:51:03 +0000</pubDate>
		<guid isPermaLink="false">#comment-53330</guid>
		<description><![CDATA[Have been doing something like this for a while for various applications using a combination of RPG and CL programs- 

1. Have a prompt program that presents the user with a selection screen and does any necessary validation of input. Query criteria are passed out of the prompt program as parameters to the query program.

2. The query program (generally a CL) builds a statement to use in an OPNQRYF. How you do that is up to you. You won&#039;t need the &quot;SELECT * FROM MYTABLE&quot; syntax, but you will need something like &quot;FIELD1 *EQ value *OR FIELD2 *EQ value2 *AND FIELD3 *EQ value3&quot; etc..

3. The OPNQRYF is set up like:
OPNQRYF    FILE((*LIBL/MYTABLE)) OPTION(*ALL) +    
             QRYSLT(&amp;QRYSRT) KEYFLD(*FILE)        
OVRDBF     FILE(MYTABLE) TOFILE(MYTABLE) SHARE(*YES)
CALL       PGM(MYPROG)                            
CLOF       OPNID(MYTABLE)                            

4. &amp;QRYSRT is the query statement you built from the initial prompts.
MYPROG is a program that will display the data in a subfile.


A couple of points to note - 

If you call MYPROG by itself (no query) it should display all of the data in MYTABLE.  So, if you already have a subfile program like that you can easily set up your query using the method above.

If MYPROG calls a subprogram that allows the user to edit the data in MYTABLE, and the edit changes data in a filed used as part of the query, the record may no longer be part of the query subset.

Regards
Mike]]></description>
		<content:encoded><![CDATA[<p>Have been doing something like this for a while for various applications using a combination of RPG and CL programs- </p>
<p>1. Have a prompt program that presents the user with a selection screen and does any necessary validation of input. Query criteria are passed out of the prompt program as parameters to the query program.</p>
<p>2. The query program (generally a CL) builds a statement to use in an OPNQRYF. How you do that is up to you. You won&#8217;t need the &#8220;SELECT * FROM MYTABLE&#8221; syntax, but you will need something like &#8220;FIELD1 *EQ value *OR FIELD2 *EQ value2 *AND FIELD3 *EQ value3&#8243; etc..</p>
<p>3. The OPNQRYF is set up like:<br />
OPNQRYF    FILE((*LIBL/MYTABLE)) OPTION(*ALL) +<br />
             QRYSLT(&amp;QRYSRT) KEYFLD(*FILE)<br />
OVRDBF     FILE(MYTABLE) TOFILE(MYTABLE) SHARE(*YES)<br />
CALL       PGM(MYPROG)<br />
CLOF       OPNID(MYTABLE)                            </p>
<p>4. &amp;QRYSRT is the query statement you built from the initial prompts.<br />
MYPROG is a program that will display the data in a subfile.</p>
<p>A couple of points to note &#8211; </p>
<p>If you call MYPROG by itself (no query) it should display all of the data in MYTABLE.  So, if you already have a subfile program like that you can easily set up your query using the method above.</p>
<p>If MYPROG calls a subprogram that allows the user to edit the data in MYTABLE, and the edit changes data in a filed used as part of the query, the record may no longer be part of the query subset.</p>
<p>Regards<br />
Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: reshmag</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/as400-i-need-to-build-a-query-to-select-records-to-be-displayed-in-subfile/#comment-53320</link>
		<dc:creator>reshmag</dc:creator>
		<pubDate>Wed, 21 May 2008 11:45:35 +0000</pubDate>
		<guid isPermaLink="false">#comment-53320</guid>
		<description><![CDATA[Plese explain your Question

Regards 
Reshma]]></description>
		<content:encoded><![CDATA[<p>Plese explain your Question</p>
<p>Regards<br />
Reshma</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 6/9 queries in 0.011 seconds using memcached
Object Caching 324/327 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-26 01:03:45 -->