 




<?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: How do I populate an SQL table created on the fly in RPGLE?</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/how-do-i-populate-an-sql-table-created-on-the-fly-in-rpgle/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/how-do-i-populate-an-sql-table-created-on-the-fly-in-rpgle/</link>
	<description></description>
	<lastBuildDate>Thu, 23 May 2013 20:47:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: stevefletcher</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-do-i-populate-an-sql-table-created-on-the-fly-in-rpgle/#comment-59956</link>
		<dc:creator>stevefletcher</dc:creator>
		<pubDate>Sun, 15 Feb 2009 21:54:16 +0000</pubDate>
		<guid isPermaLink="false">#comment-59956</guid>
		<description><![CDATA[I found the answer over on SystemiNetwork with the help of Scott Klement. 

Use parameter markers, one for each field/column. Set the sql statement as: 
WkFld = &#039;Insert Into &#039; + WkOutFile +                        
        &#039; Values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)&#039;;

Prepare the statement: 
Exec Sql PREPARE S2 from :WkFld;                            

Then, execute (instead of the Execute Immediate statement) in the loop: 
Exec Sql Execute S2 USING :@Fulotrwt :@IndVar; 

Thanks again for the assistance.

Steve]]></description>
		<content:encoded><![CDATA[<p>I found the answer over on SystemiNetwork with the help of Scott Klement. </p>
<p>Use parameter markers, one for each field/column. Set the sql statement as:<br />
WkFld = &#8216;Insert Into &#8216; + WkOutFile +<br />
        &#8216; Values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)&#8217;;</p>
<p>Prepare the statement:<br />
Exec Sql PREPARE S2 from :WkFld;                            </p>
<p>Then, execute (instead of the Execute Immediate statement) in the loop:<br />
Exec Sql Execute S2 USING :@Fulotrwt :@IndVar; </p>
<p>Thanks again for the assistance.</p>
<p>Steve</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: philpl1jb</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-do-i-populate-an-sql-table-created-on-the-fly-in-rpgle/#comment-59954</link>
		<dc:creator>philpl1jb</dc:creator>
		<pubDate>Sun, 15 Feb 2009 19:14:25 +0000</pubDate>
		<guid isPermaLink="false">#comment-59954</guid>
		<description><![CDATA[Steve 
I&#039;m not using RPGSQL enough to be sure
WkFld = &#039;Insert Into &#039; + WkOutFile + &#039; Values (@Fulotrwt)&#039;;
1.  should there be a : in :@FULOTRWT above?

or expand it

WkFld = &#039;Insert Into &#039; + WkOutFile + &#039; Values (&#039; + Field1 + &#039;,&#039; + Field2+&#039;,&#039;&#039;CharFld3+&#039;&#039;&#039;)&#039;
something like this - note I&#039;ve provided double quotes arount the in spots where SQL should be passed a single quote.


Phil]]></description>
		<content:encoded><![CDATA[<p>Steve<br />
I&#8217;m not using RPGSQL enough to be sure<br />
WkFld = &#8216;Insert Into &#8216; + WkOutFile + &#8216; Values (@Fulotrwt)&#8217;;<br />
1.  should there be a : in :@FULOTRWT above?</p>
<p>or expand it</p>
<p>WkFld = &#8216;Insert Into &#8216; + WkOutFile + &#8216; Values (&#8216; + Field1 + &#8216;,&#8217; + Field2+&#8217;,&#8221;CharFld3+&#8221;&#8217;)&#8217;<br />
something like this &#8211; note I&#8217;ve provided double quotes arount the in spots where SQL should be passed a single quote.</p>
<p>Phil</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stevefletcher</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-do-i-populate-an-sql-table-created-on-the-fly-in-rpgle/#comment-59947</link>
		<dc:creator>stevefletcher</dc:creator>
		<pubDate>Sat, 14 Feb 2009 23:11:35 +0000</pubDate>
		<guid isPermaLink="false">#comment-59947</guid>
		<description><![CDATA[Thanks for your response Phil. 

I&#039;m hoping to do this using SQL. I&#039;ve tried several things, but can&#039;t get it to work. This seems the most promising, but I&#039;m not quite there: 
&lt;pre&gt;
WkLib = &#039;MYLIB&#039;;                                    
WkTable = &#039;OTR&#039; + %Char(%SubDt(%Timestamp:*MS));        
WkOutFile = WkLib + &#039;/&#039; + WkTable;                      
WkFld = &#039;Create Table &#039;+ WkOutFile + &#039; LIKE FULOTRWT&#039;;  
Exec Sql Execute Immediate :WkFld;  

Exec Sql PREPARE S1 FROM :SqlStmt;      
Exec Sql DECLARE C1 CURSOR FOR S1;      
Exec Sql OPEN C1;           

WkFld = &#039;Insert Into &#039; + WkOutFile + &#039; Values (@Fulotrwt)&#039;;

Exec Sql FETCH NEXT FROM C1 INTO :@Fulotrwt :@IndVar;       
                                                            
Dow SqlCod = 0;                                             

  Exec Sql Execute Immediate :WkFld;                        
                                                            
  Exec Sql FETCH NEXT FROM C1 INTO :@Fulotrwt :@IndVar;     
                                                            
Enddo;          
&lt;/pre&gt; 

First, I create the table named OTR123000 (varying number) in library MYLIB like the existing table FULOTRWT.

Then I prepare/declare/open a cursor for a passed-in sql statement to retrieve data from an existing table.

Then I create a variable (WkFld) with the sql statement to be executed (@Fulotrwt is a data structure based on the existing table), fetch a record, and attempt to insert it into the dynamic table (repeatedly).

Each time the &lt;ul&gt;
Exec Sql Execute Immediate :WkFld;&lt;/ul&gt; runs I get an sql 206 error with the message &quot;Column @FULOTRWT not in specified tables.&quot; 

I also tried naming the columns specifically instead of the data structure, but then I get the same error but with the column name instead of the data structure. 

I would appreciate it if anyone can tell me what I&#039;m missing here. 

Thanks, 
Steve]]></description>
		<content:encoded><![CDATA[<p>Thanks for your response Phil. </p>
<p>I&#8217;m hoping to do this using SQL. I&#8217;ve tried several things, but can&#8217;t get it to work. This seems the most promising, but I&#8217;m not quite there: </p>
<pre>
WkLib = 'MYLIB';                                    
WkTable = 'OTR' + %Char(%SubDt(%Timestamp:*MS));        
WkOutFile = WkLib + '/' + WkTable;                      
WkFld = 'Create Table '+ WkOutFile + ' LIKE FULOTRWT';  
Exec Sql Execute Immediate :WkFld;  

Exec Sql PREPARE S1 FROM :SqlStmt;      
Exec Sql DECLARE C1 CURSOR FOR S1;      
Exec Sql OPEN C1;           

WkFld = 'Insert Into ' + WkOutFile + ' Values (@Fulotrwt)';

Exec Sql FETCH NEXT FROM C1 INTO :@Fulotrwt :@IndVar;       
                                                            
Dow SqlCod = 0;                                             

  Exec Sql Execute Immediate :WkFld;                        
                                                            
  Exec Sql FETCH NEXT FROM C1 INTO :@Fulotrwt :@IndVar;     
                                                            
Enddo;          
</pre>
<p>First, I create the table named OTR123000 (varying number) in library MYLIB like the existing table FULOTRWT.</p>
<p>Then I prepare/declare/open a cursor for a passed-in sql statement to retrieve data from an existing table.</p>
<p>Then I create a variable (WkFld) with the sql statement to be executed (@Fulotrwt is a data structure based on the existing table), fetch a record, and attempt to insert it into the dynamic table (repeatedly).</p>
<p>Each time the
<ul>
Exec Sql Execute Immediate :WkFld;</ul>
<p> runs I get an sql 206 error with the message &#8220;Column @FULOTRWT not in specified tables.&#8221; </p>
<p>I also tried naming the columns specifically instead of the data structure, but then I get the same error but with the column name instead of the data structure. </p>
<p>I would appreciate it if anyone can tell me what I&#8217;m missing here. </p>
<p>Thanks,<br />
Steve</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.032 seconds using memcached
Object Caching 295/301 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-23 21:18:11 -->