 




<?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: Building the Key in RPG/400 itself</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/building-the-key-in-rpg400-itself/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/building-the-key-in-rpg400-itself/</link>
	<description></description>
	<lastBuildDate>Thu, 23 May 2013 01:41:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/building-the-key-in-rpg400-itself/#comment-95209</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Fri, 12 Aug 2011 02:41:41 +0000</pubDate>
		<guid isPermaLink="false">#comment-95209</guid>
		<description><![CDATA[&lt;i&gt;You can create keys on the fly using OPNQRYF...&lt;/i&gt;

You can indeed create keyed files with OPNQRYF. But that&#039;s not creating the key in RPG, nor does it allow RPG/400 to access a file by key if the program isn&#039;t already written and compiled to process a keyed file.

If an externally-described file is keyed and the program is written to access by key, there doesn&#039;t seem to be any point to the original question unless it&#039;s asking about accessing by key when the program doesn&#039;t already define the file as keyed. OPNQRYF won&#039;t help with that. The point of the question has unfortunately never been made.

Tom]]></description>
		<content:encoded><![CDATA[<p><i>You can create keys on the fly using OPNQRYF&#8230;</i></p>
<p>You can indeed create keyed files with OPNQRYF. But that&#8217;s not creating the key in RPG, nor does it allow RPG/400 to access a file by key if the program isn&#8217;t already written and compiled to process a keyed file.</p>
<p>If an externally-described file is keyed and the program is written to access by key, there doesn&#8217;t seem to be any point to the original question unless it&#8217;s asking about accessing by key when the program doesn&#8217;t already define the file as keyed. OPNQRYF won&#8217;t help with that. The point of the question has unfortunately never been made.</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: splat</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/building-the-key-in-rpg400-itself/#comment-95179</link>
		<dc:creator>splat</dc:creator>
		<pubDate>Thu, 11 Aug 2011 14:59:15 +0000</pubDate>
		<guid isPermaLink="false">#comment-95179</guid>
		<description><![CDATA[You can create keys on the fly using OPNQRYF and process them in an RPGLE program.  The following fragments are from some programs written some time ago:

&lt;pre&gt;OVRDBF     FILE(QADSPDBR) TOFILE(QTEMP/QADSPDBR) +       
             MBR([member name]) SECURE(*YES) SHARE(*YES)       
OPNQRYF    FILE((QTEMP/QADSPDBR [member name]))               +
           QRYSLT(&#039;(WHNO *NE 0)&#039;)                       +
           KEYFLD((WHRLI)                               +
                  (WHRFI)                               +
                  (WHRELI)                              +
                  (WHREFI))&lt;/pre&gt;                              

&lt;pre&gt;FQadspdbr  If   f  372    30aiDisk    keyloc(1)   &lt;/pre&gt;

&lt;pre&gt;D Ddbr          e Ds                  extname(qadspdbr)
D  dbjref       e                     extfld(whjref)   
D  dbsysn       e                     extfld(whsysn)&lt;/pre&gt;

&lt;pre&gt;D                 Ds                
D  qwhf01                 1     20  
D  qwhf02                 1     30&lt;/pre&gt;  

&lt;pre&gt;IQadspdbr  ba  02                              
I                                  1  372  ddbr&lt;/pre&gt;

&lt;pre&gt;Csr   qwhf01        SetLl     Qadspdbr                                 
Csr                 Dow       not *in31                                
Csr   qwhf01        ReadE     Qadspdbr                               31
Csr                 If        not *in31                                

Csr                 EndDo&lt;/pre&gt;

Let me note that even though it can be done, it&#039;s not something I&#039;d likely do again - this was as much an experiment as anything else.  But the program, originally written in 1988, does still work.]]></description>
		<content:encoded><![CDATA[<p>You can create keys on the fly using OPNQRYF and process them in an RPGLE program.  The following fragments are from some programs written some time ago:</p>
<pre>OVRDBF     FILE(QADSPDBR) TOFILE(QTEMP/QADSPDBR) +       
             MBR([member name]) SECURE(*YES) SHARE(*YES)       
OPNQRYF    FILE((QTEMP/QADSPDBR [member name]))               +
           QRYSLT('(WHNO *NE 0)')                       +
           KEYFLD((WHRLI)                               +
                  (WHRFI)                               +
                  (WHRELI)                              +
                  (WHREFI))</pre>
<pre>FQadspdbr  If   f  372    30aiDisk    keyloc(1)   </pre>
<pre>D Ddbr          e Ds                  extname(qadspdbr)
D  dbjref       e                     extfld(whjref)   
D  dbsysn       e                     extfld(whsysn)</pre>
<pre>D                 Ds                
D  qwhf01                 1     20  
D  qwhf02                 1     30</pre>
<pre>IQadspdbr  ba  02                              
I                                  1  372  ddbr</pre>
<pre>Csr   qwhf01        SetLl     Qadspdbr                                 
Csr                 Dow       not *in31                                
Csr   qwhf01        ReadE     Qadspdbr                               31
Csr                 If        not *in31                                

Csr                 EndDo</pre>
<p>Let me note that even though it can be done, it&#8217;s not something I&#8217;d likely do again &#8211; this was as much an experiment as anything else.  But the program, originally written in 1988, does still work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pgmbob</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/building-the-key-in-rpg400-itself/#comment-95131</link>
		<dc:creator>pgmbob</dc:creator>
		<pubDate>Wed, 10 Aug 2011 04:22:58 +0000</pubDate>
		<guid isPermaLink="false">#comment-95131</guid>
		<description><![CDATA[My favorite is when I have two files and need joined records keyed by fields in both files. I create a &quot;format&quot; work file with the fields from both files.  the OVRDBF is the first file overriden to my work file. The program references my work file for the compile. Use OPNQRYF join the 2 files and build the keys.The work file goes away when the job ends.The same workfile can be used over for a different sequence.]]></description>
		<content:encoded><![CDATA[<p>My favorite is when I have two files and need joined records keyed by fields in both files. I create a &#8220;format&#8221; work file with the fields from both files.  the OVRDBF is the first file overriden to my work file. The program references my work file for the compile. Use OPNQRYF join the 2 files and build the keys.The work file goes away when the job ends.The same workfile can be used over for a different sequence.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yorkshireman</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/building-the-key-in-rpg400-itself/#comment-95102</link>
		<dc:creator>yorkshireman</dc:creator>
		<pubDate>Tue, 09 Aug 2011 09:22:55 +0000</pubDate>
		<guid isPermaLink="false">#comment-95102</guid>
		<description><![CDATA[OPNQRYF woudl seem to be a way to go here..]]></description>
		<content:encoded><![CDATA[<p>OPNQRYF woudl seem to be a way to go here..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cwc</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/building-the-key-in-rpg400-itself/#comment-54087</link>
		<dc:creator>cwc</dc:creator>
		<pubDate>Fri, 20 Jun 2008 18:00:03 +0000</pubDate>
		<guid isPermaLink="false">#comment-54087</guid>
		<description><![CDATA[Hi Sloopy, 

Yes, an SQL index can be used inside of an RPG or other HLL program.  This is because an SQL index is implemented as a logical file, so an application program doesn&#039;t know the difference.  

However, an SQL statement cannot refer directly to an index; it needs to refer to the base table or physical file, and then the SQL query engine will choose the index it uses to access the data behind the scenes.  So an embedded SQL Select should use the physical file name, while an application program can use either one, depending on what keys it needs.  

I learned more on this when one of our important data files exceeded its maximum record count, and we implemented DB2 Multisystem Support as a solution.  So we have an SQL index over a multiple membered file, and that index is built over all members/SQL partitions.  And our application programs just see one large file with the same keyed access they had before.]]></description>
		<content:encoded><![CDATA[<p>Hi Sloopy, </p>
<p>Yes, an SQL index can be used inside of an RPG or other HLL program.  This is because an SQL index is implemented as a logical file, so an application program doesn&#8217;t know the difference.  </p>
<p>However, an SQL statement cannot refer directly to an index; it needs to refer to the base table or physical file, and then the SQL query engine will choose the index it uses to access the data behind the scenes.  So an embedded SQL Select should use the physical file name, while an application program can use either one, depending on what keys it needs.  </p>
<p>I learned more on this when one of our important data files exceeded its maximum record count, and we implemented DB2 Multisystem Support as a solution.  So we have an SQL index over a multiple membered file, and that index is built over all members/SQL partitions.  And our application programs just see one large file with the same keyed access they had before.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sloopy</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/building-the-key-in-rpg400-itself/#comment-54084</link>
		<dc:creator>sloopy</dc:creator>
		<pubDate>Fri, 20 Jun 2008 15:36:57 +0000</pubDate>
		<guid isPermaLink="false">#comment-54084</guid>
		<description><![CDATA[Correct me if I&#039;m wrong (which is often the case), but, CWC, can&#039;t an SQL index only be used by SQL? You wouldn&#039;t be able to open it in a standard RPGIV program?

But I do agree with the thrust of your comments - what is Ali trying to do?

If, Ali, you want to build a keyed view of your data based on what users enter on a screen - well, this is a good job for embedded SQL. You should not be thinking of creating a logical file &#039;on-demand&#039; for screen displays!

Creating a logical file, or an SQL view, is a matter of analysis and judgement. These things are expected to be permanent, and so you would create a keyed view when that view will make your day-to-day processing faster and less complicated.

Especially if the based-on physical file is large!

There are plenty of methods for speeding up screen programs where the users can make lots of different selections. Some depend on a good stock of logical files with different, useful keys; and others depend on embedded SQL, which is a better way to go than creating logicals just for a particular screen. OPNQRYF is not nowadays a good method.

Ali, we can give you more specific advice if you can tell us WHY you want to create logicals from inside your RPG programs, maybe giving us some examples....?

Regards,

Sloopy]]></description>
		<content:encoded><![CDATA[<p>Correct me if I&#8217;m wrong (which is often the case), but, CWC, can&#8217;t an SQL index only be used by SQL? You wouldn&#8217;t be able to open it in a standard RPGIV program?</p>
<p>But I do agree with the thrust of your comments &#8211; what is Ali trying to do?</p>
<p>If, Ali, you want to build a keyed view of your data based on what users enter on a screen &#8211; well, this is a good job for embedded SQL. You should not be thinking of creating a logical file &#8216;on-demand&#8217; for screen displays!</p>
<p>Creating a logical file, or an SQL view, is a matter of analysis and judgement. These things are expected to be permanent, and so you would create a keyed view when that view will make your day-to-day processing faster and less complicated.</p>
<p>Especially if the based-on physical file is large!</p>
<p>There are plenty of methods for speeding up screen programs where the users can make lots of different selections. Some depend on a good stock of logical files with different, useful keys; and others depend on embedded SQL, which is a better way to go than creating logicals just for a particular screen. OPNQRYF is not nowadays a good method.</p>
<p>Ali, we can give you more specific advice if you can tell us WHY you want to create logicals from inside your RPG programs, maybe giving us some examples&#8230;.?</p>
<p>Regards,</p>
<p>Sloopy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cwc</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/building-the-key-in-rpg400-itself/#comment-54039</link>
		<dc:creator>cwc</dc:creator>
		<pubDate>Thu, 19 Jun 2008 14:32:23 +0000</pubDate>
		<guid isPermaLink="false">#comment-54039</guid>
		<description><![CDATA[Instead of creating the file through DDS, I think it would be much cleaner to create the file via embedded SQL, with a Create Index statement.  That way, the one step would take care of it all.  

However, I question what the value of creating a dynamic index or logical file really would be, as it would take time to create the index, depending on how many records are in the physical file or table.  And would you then be keeping that index, or deleting it once you&#039;re done?  Without knowing how your database files are designed, it still sounds like a lot of extra overhead to me.  

You&#039;d be better off using embedded SQL to run a Select statement to retrieve the result set you want and then loop through each record for whatever processing you want to do.  

Also, you mentioned RPG/400 -- I hope you&#039;re not using RPG III to do this?  If so, I urge you to use the modern version of the language (RPG IV), which gives much more flexibility and power over what you can do and how you can accomplish it.]]></description>
		<content:encoded><![CDATA[<p>Instead of creating the file through DDS, I think it would be much cleaner to create the file via embedded SQL, with a Create Index statement.  That way, the one step would take care of it all.  </p>
<p>However, I question what the value of creating a dynamic index or logical file really would be, as it would take time to create the index, depending on how many records are in the physical file or table.  And would you then be keeping that index, or deleting it once you&#8217;re done?  Without knowing how your database files are designed, it still sounds like a lot of extra overhead to me.  </p>
<p>You&#8217;d be better off using embedded SQL to run a Select statement to retrieve the result set you want and then loop through each record for whatever processing you want to do.  </p>
<p>Also, you mentioned RPG/400 &#8212; I hope you&#8217;re not using RPG III to do this?  If so, I urge you to use the modern version of the language (RPG IV), which gives much more flexibility and power over what you can do and how you can accomplish it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gilly400</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/building-the-key-in-rpg400-itself/#comment-54005</link>
		<dc:creator>gilly400</dc:creator>
		<pubDate>Wed, 18 Jun 2008 15:52:28 +0000</pubDate>
		<guid isPermaLink="false">#comment-54005</guid>
		<description><![CDATA[Hi Ali,

I wouldn&#039;t recommend this way of doing this, as it can get quite messy, but here&#039;s an overview of how it works :-

First create a Source File in your QTEMP library, and add a Source Member to it.  I would take care of this in a CL program before your RPG.  OVRDBF to your Source File &amp; Member.
&lt;pre&gt;

CRTSRCPF QTEMP/QDDSSRC
ADDPFM QTEMP/QDDSSRC MEMBER
OVRDBF SOURCE QTEMP/QDDSSRC MEMBER
CALL Yourpgm

&lt;/pre&gt;
In Yourpgm you will need the file SOURCE defined for output.  Then you write one record for the definition of the record format and one record for the PFILE, followed one record for each of the keys you need in your logical file.

Then from Yourpgm you execute a CRTLF using QCMDEXC :-
&lt;pre&gt;

CRTLF Yourlib/YourLF QTEMP/QDDSSRC MEMBER

&lt;/pre&gt;
You should now have your logical file with th keys you want.

Regards,

Martin Gilbert.]]></description>
		<content:encoded><![CDATA[<p>Hi Ali,</p>
<p>I wouldn&#8217;t recommend this way of doing this, as it can get quite messy, but here&#8217;s an overview of how it works :-</p>
<p>First create a Source File in your QTEMP library, and add a Source Member to it.  I would take care of this in a CL program before your RPG.  OVRDBF to your Source File &amp; Member.</p>
<pre>

CRTSRCPF QTEMP/QDDSSRC
ADDPFM QTEMP/QDDSSRC MEMBER
OVRDBF SOURCE QTEMP/QDDSSRC MEMBER
CALL Yourpgm

</pre>
<p>In Yourpgm you will need the file SOURCE defined for output.  Then you write one record for the definition of the record format and one record for the PFILE, followed one record for each of the keys you need in your logical file.</p>
<p>Then from Yourpgm you execute a CRTLF using QCMDEXC :-</p>
<pre>

CRTLF Yourlib/YourLF QTEMP/QDDSSRC MEMBER

</pre>
<p>You should now have your logical file with th keys you want.</p>
<p>Regards,</p>
<p>Martin Gilbert.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alicsc</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/building-the-key-in-rpg400-itself/#comment-53993</link>
		<dc:creator>alicsc</dc:creator>
		<pubDate>Wed, 18 Jun 2008 12:34:04 +0000</pubDate>
		<guid isPermaLink="false">#comment-53993</guid>
		<description><![CDATA[Hi Martin,

Can you pls give one example for this statement   &#039;You *could* create a logical file by writing a DDS source file from your RPG program ?.

I did not get this how to do.

Thanks,
Ali]]></description>
		<content:encoded><![CDATA[<p>Hi Martin,</p>
<p>Can you pls give one example for this statement   &#8216;You *could* create a logical file by writing a DDS source file from your RPG program ?.</p>
<p>I did not get this how to do.</p>
<p>Thanks,<br />
Ali</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gilly400</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/building-the-key-in-rpg400-itself/#comment-53989</link>
		<dc:creator>gilly400</dc:creator>
		<pubDate>Wed, 18 Jun 2008 08:56:04 +0000</pubDate>
		<guid isPermaLink="false">#comment-53989</guid>
		<description><![CDATA[Hi,

You *could* create a logical file by writing a DDS source file from your RPG program and calling QCMDEXC to run a CRTLF to build the logical file, then use an OVRDBF to access that file from your program, but I wouldn&#039;t recommend this.

Regards,

Martin Gilbert.]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>You *could* create a logical file by writing a DDS source file from your RPG program and calling QCMDEXC to run a CRTLF to build the logical file, then use an OVRDBF to access that file from your program, but I wouldn&#8217;t recommend this.</p>
<p>Regards,</p>
<p>Martin Gilbert.</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.038 seconds using memcached
Object Caching 393/399 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-23 02:11:11 -->