 




<?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: Need help with setvar for iSeries query manager using not in ()</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/need-help-with-setvar-for-qm-using-not-in/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/need-help-with-setvar-for-qm-using-not-in/</link>
	<description></description>
	<lastBuildDate>Fri, 24 May 2013 17:13:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/need-help-with-setvar-for-qm-using-not-in/#comment-84464</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Mon, 29 Nov 2010 07:36:44 +0000</pubDate>
		<guid isPermaLink="false">#comment-84464</guid>
		<description><![CDATA[As might be evidenced by this question, &quot;simplification&quot; sometimes complicates things. But I understand. Glad it&#039;s working.

Tom]]></description>
		<content:encoded><![CDATA[<p>As might be evidenced by this question, &#8220;simplification&#8221; sometimes complicates things. But I understand. Glad it&#8217;s working.</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vgp</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/need-help-with-setvar-for-qm-using-not-in/#comment-84448</link>
		<dc:creator>vgp</dc:creator>
		<pubDate>Sun, 28 Nov 2010 16:02:53 +0000</pubDate>
		<guid isPermaLink="false">#comment-84448</guid>
		<description><![CDATA[I am working now!!!!  Thanks

Sorry guys,
I had not posted the full QM to keep it simple and I have a CASE statement that was AFTER the Excludes in my QM but BEFORE it in the Command and RPG call.   When I corrected the order of those...wala the Excludes works!!

The extra comma was my cut and paste and typing.  

Thanks so much for the help with the proper Quotes and syntax.  
VGP]]></description>
		<content:encoded><![CDATA[<p>I am working now!!!!  Thanks</p>
<p>Sorry guys,<br />
I had not posted the full QM to keep it simple and I have a CASE statement that was AFTER the Excludes in my QM but BEFORE it in the Command and RPG call.   When I corrected the order of those&#8230;wala the Excludes works!!</p>
<p>The extra comma was my cut and paste and typing.  </p>
<p>Thanks so much for the help with the proper Quotes and syntax.<br />
VGP</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/need-help-with-setvar-for-qm-using-not-in/#comment-84406</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Fri, 26 Nov 2010 07:50:40 +0000</pubDate>
		<guid isPermaLink="false">#comment-84406</guid>
		<description><![CDATA[The only use of WHEN in a SELECT clause should be in a CASE structure, AFAIK. The extra comma would cause the parser to assume that &quot;FROM&quot; was intended to be a column name even if it&#039;s a reserved word. How that morphs into expecting WHEN...?

In any case, the EXCLUDES replacement variable will work as it was last described.

Let&#039;s see how the next live run goes.

Tom]]></description>
		<content:encoded><![CDATA[<p>The only use of WHEN in a SELECT clause should be in a CASE structure, AFAIK. The extra comma would cause the parser to assume that &#8220;FROM&#8221; was intended to be a column name even if it&#8217;s a reserved word. How that morphs into expecting WHEN&#8230;?</p>
<p>In any case, the EXCLUDES replacement variable will work as it was last described.</p>
<p>Let&#8217;s see how the next live run goes.</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/need-help-with-setvar-for-qm-using-not-in/#comment-84359</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Thu, 25 Nov 2010 00:50:57 +0000</pubDate>
		<guid isPermaLink="false">#comment-84359</guid>
		<description><![CDATA[Thanks Tom.

&quot;&lt;i&gt;The overlooked comma might be the biggest problem. I’m not at all clear why you got the error text “Token ‘ ‘ was not valid. Valid tokens: WHEN”. That doesn’t make much sense to me&lt;/i&gt;.&quot;

Yes, the error messages were misleading, and I think that was the reason why nobody noticed the extra comma which would definitely cause a syntax error.

And, it seems that there is no way to post two consecutive apostrophes without they becoming a double quotation mark.]]></description>
		<content:encoded><![CDATA[<p>Thanks Tom.</p>
<p>&#8220;<i>The overlooked comma might be the biggest problem. I’m not at all clear why you got the error text “Token ‘ ‘ was not valid. Valid tokens: WHEN”. That doesn’t make much sense to me</i>.&#8221;</p>
<p>Yes, the error messages were misleading, and I think that was the reason why nobody noticed the extra comma which would definitely cause a syntax error.</p>
<p>And, it seems that there is no way to post two consecutive apostrophes without they becoming a double quotation mark.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/need-help-with-setvar-for-qm-using-not-in/#comment-84355</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Thu, 25 Nov 2010 00:19:42 +0000</pubDate>
		<guid isPermaLink="false">#comment-84355</guid>
		<description><![CDATA[I created a table named FILENAME with column names and attributes matching the QM query. This QM query worked:&lt;pre&gt;
SELECT
Fileinvno, fileinvdte, filecode  from filename where
TRIM(filecmp) = &amp;Q&amp;COMPANY&amp;Q
AND fileinvdte &gt;= &amp;FROMDATE
AND fileinvdte &lt;= &amp;TODATE
AND filecode NOT IN &amp;EXCLUDES&lt;/pre&gt;
Two differences from your pasted code -- no comma after FILECODE and no blank line after the WHERE token. The blank line might be irrelevant, but the comma was a definite syntax error.

And since Carlosdl is also interested and I&#039;m not confident in the editor either, here&#039;s a straight paste:

SELECT
Fileinvno, fileinvdte, filecode  from filename where
TRIM(filecmp) = &amp;Q&amp;COMPANY&amp;Q
AND fileinvdte &gt;= &amp;FROMDATE
AND fileinvdte &lt;= &amp;TODATE
AND filecode NOT IN &amp;EXCLUDES

The STRQMQRY ran with no errors. The command looked like:&lt;pre&gt;
STRQMQRY QMQRY(TSTQM)
         OUTPUT(*OUTFILE)
         OUTFILE(QTEMP/MYFILE)
         SETVAR((Q &#039;&#039;&#039;&#039;)
                (COMPANY 1)
                (FROMDATE 19400101)
                (TODATE 20391231)
                (EXCLUDES &#039;(&#039;&#039;A&#039;&#039;,&#039;&#039;P&#039;&#039;,&#039;&#039;B&#039;&#039;)&#039;))&lt;/pre&gt;
Or in straight paste:

STRQMQRY QMQRY(TSTQM)
         OUTPUT(*OUTFILE)
         OUTFILE(QTEMP/MYFILE)
         SETVAR((Q &#039;&#039;&#039;&#039;)
                (COMPANY 1)
                (FROMDATE 19400101)
                (TODATE 20391231)
                (EXCLUDES &#039;(&#039;&#039;A&#039;&#039;,&#039;&#039;P&#039;&#039;,&#039;&#039;B&#039;&#039;)&#039;))

The overlooked comma might be the biggest problem. I&#039;m not at all clear why you got the error text &quot;Token ‘ ‘ was not valid. Valid tokens: WHEN&quot;. That doesn&#039;t make much sense to me.

Tom]]></description>
		<content:encoded><![CDATA[<p>I created a table named FILENAME with column names and attributes matching the QM query. This QM query worked:
<pre>
SELECT
Fileinvno, fileinvdte, filecode  from filename where
TRIM(filecmp) = &amp;Q&amp;COMPANY&amp;Q
AND fileinvdte &gt;= &amp;FROMDATE
AND fileinvdte &lt;= &amp;TODATE
AND filecode NOT IN &amp;EXCLUDES</pre>
<p>Two differences from your pasted code &#8212; no comma after FILECODE and no blank line after the WHERE token. The blank line might be irrelevant, but the comma was a definite syntax error.</p>
<p>And since Carlosdl is also interested and I&#8217;m not confident in the editor either, here&#8217;s a straight paste:</p>
<p>SELECT<br />
Fileinvno, fileinvdte, filecode  from filename where<br />
TRIM(filecmp) = &amp;Q&amp;COMPANY&amp;Q<br />
AND fileinvdte &gt;= &amp;FROMDATE<br />
AND fileinvdte &lt;= &amp;TODATE<br />
AND filecode NOT IN &amp;EXCLUDES</p>
<p>The STRQMQRY ran with no errors. The command looked like:
<pre>
STRQMQRY QMQRY(TSTQM)
         OUTPUT(*OUTFILE)
         OUTFILE(QTEMP/MYFILE)
         SETVAR((Q '''')
                (COMPANY 1)
                (FROMDATE 19400101)
                (TODATE 20391231)
                (EXCLUDES '(''A'',''P'',''B'')'))</pre>
<p>Or in straight paste:</p>
<p>STRQMQRY QMQRY(TSTQM)<br />
         OUTPUT(*OUTFILE)<br />
         OUTFILE(QTEMP/MYFILE)<br />
         SETVAR((Q &#8221;&#8221;)<br />
                (COMPANY 1)<br />
                (FROMDATE 19400101)<br />
                (TODATE 20391231)<br />
                (EXCLUDES &#8216;(&#8221;A&#8221;,&#8221;P&#8221;,&#8221;B&#8221;)&#8217;))</p>
<p>The overlooked comma might be the biggest problem. I&#8217;m not at all clear why you got the error text &#8220;Token ‘ ‘ was not valid. Valid tokens: WHEN&#8221;. That doesn&#8217;t make much sense to me.</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vgp</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/need-help-with-setvar-for-qm-using-not-in/#comment-84336</link>
		<dc:creator>vgp</dc:creator>
		<pubDate>Wed, 24 Nov 2010 17:16:49 +0000</pubDate>
		<guid isPermaLink="false">#comment-84336</guid>
		<description><![CDATA[&lt;i&gt;Do you have a variable number of codes? Or are there always three of them? Are there other codes that might be used in other runs of the program?&lt;/i&gt;

yes, it is variable, up to 6 allowed. And from a selection of 18 different possible codes.

yes they are all single quotes. 

Tom, thanks for the suggestion.... I removed the &amp;q and it is now
AND filecode NOT IN &amp;EXCLUDES 

Here is the end result of the command in the RPG.
STRQMQRY QMQRY(qry1) OUTPUT(*OUTFILE) OUTFILE(QTEMP/myfile) SETVAR((Q ””) (COMPANY 1 ) (FROMDATE 19400101) (TODATE 20391231) (EXCLUDES ‘(”A”,”P”,”B”)’))

The error message is
Token &#039;  &#039; was not valid. Valid tokens: WHEN
RUN QUERY command failed with SQLCODE -104
RUN QUERY command ended due to error.
STRQMQRY command failed.]]></description>
		<content:encoded><![CDATA[<p><i>Do you have a variable number of codes? Or are there always three of them? Are there other codes that might be used in other runs of the program?</i></p>
<p>yes, it is variable, up to 6 allowed. And from a selection of 18 different possible codes.</p>
<p>yes they are all single quotes. </p>
<p>Tom, thanks for the suggestion&#8230;. I removed the &amp;q and it is now<br />
AND filecode NOT IN &amp;EXCLUDES </p>
<p>Here is the end result of the command in the RPG.<br />
STRQMQRY QMQRY(qry1) OUTPUT(*OUTFILE) OUTFILE(QTEMP/myfile) SETVAR((Q ””) (COMPANY 1 ) (FROMDATE 19400101) (TODATE 20391231) (EXCLUDES ‘(”A”,”P”,”B”)’))</p>
<p>The error message is<br />
Token &#8216;  &#8216; was not valid. Valid tokens: WHEN<br />
RUN QUERY command failed with SQLCODE -104<br />
RUN QUERY command ended due to error.<br />
STRQMQRY command failed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/need-help-with-setvar-for-qm-using-not-in/#comment-84321</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Wed, 24 Nov 2010 14:37:01 +0000</pubDate>
		<guid isPermaLink="false">#comment-84321</guid>
		<description><![CDATA[Nope, they look the same, so maybe VGP is using the correct quotation marks and my last comment should be ignored.]]></description>
		<content:encoded><![CDATA[<p>Nope, they look the same, so maybe VGP is using the correct quotation marks and my last comment should be ignored.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/need-help-with-setvar-for-qm-using-not-in/#comment-84320</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Wed, 24 Nov 2010 14:34:11 +0000</pubDate>
		<guid isPermaLink="false">#comment-84320</guid>
		<description><![CDATA[&lt;pre&gt;EXCLUDES ‘(”A”,”P”,”B”)’&lt;/pre&gt;

It could be the site&#039;s editor, but the filecodes seem to be enclosed in double quotes, but I guess a pair of single quotes (if the single quote is used as an escape character) should be used.

I&#039;m not going to use the code tool to see if the quotes show correctly without it:

Instead of 

EXCLUDES ‘(&quot;A&quot;,&quot;P&quot;,&quot;B&quot;)’

this could be needed:

EXCLUDES &#039;(&#039;&#039;A&#039;&#039;,&#039;&#039;P&#039;&#039;,&#039;&#039;B&#039;&#039;)’]]></description>
		<content:encoded><![CDATA[<pre>EXCLUDES ‘(”A”,”P”,”B”)’</pre>
<p>It could be the site&#8217;s editor, but the filecodes seem to be enclosed in double quotes, but I guess a pair of single quotes (if the single quote is used as an escape character) should be used.</p>
<p>I&#8217;m not going to use the code tool to see if the quotes show correctly without it:</p>
<p>Instead of </p>
<p>EXCLUDES ‘(&#8220;A&#8221;,&#8221;P&#8221;,&#8221;B&#8221;)’</p>
<p>this could be needed:</p>
<p>EXCLUDES &#8216;(&#8221;A&#8221;,&#8221;P&#8221;,&#8221;B&#8221;)’</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/need-help-with-setvar-for-qm-using-not-in/#comment-84303</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Wed, 24 Nov 2010 05:30:08 +0000</pubDate>
		<guid isPermaLink="false">#comment-84303</guid>
		<description><![CDATA[&lt;pre&gt;AND filecode NOT IN &amp;Q&amp;EXCLUDES&amp;Q&lt;/pre&gt;

Now you should use:&lt;pre&gt;
AND filecode NOT IN &amp;EXCLUDES&lt;/pre&gt;
The outer quotes won&#039;t be in the SQL statement. You want the result to look this way:&lt;pre&gt;
AND filecode NOT IN (’A&#039;,’B&#039;,’P&#039;)&lt;/pre&gt;
No quotes outside of the parens.

Do you have a variable number of codes? Or are there always three of them? Are there other codes that might be used in other runs of the program?

Tom]]></description>
		<content:encoded><![CDATA[<pre>AND filecode NOT IN &amp;Q&amp;EXCLUDES&amp;Q</pre>
<p>Now you should use:
<pre>
AND filecode NOT IN &amp;EXCLUDES</pre>
<p>The outer quotes won&#8217;t be in the SQL statement. You want the result to look this way:
<pre>
AND filecode NOT IN (’A',’B',’P')</pre>
<p>No quotes outside of the parens.</p>
<p>Do you have a variable number of codes? Or are there always three of them? Are there other codes that might be used in other runs of the program?</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vgp</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/need-help-with-setvar-for-qm-using-not-in/#comment-84218</link>
		<dc:creator>vgp</dc:creator>
		<pubDate>Tue, 23 Nov 2010 06:47:58 +0000</pubDate>
		<guid isPermaLink="false">#comment-84218</guid>
		<description><![CDATA[Tom,
Still is not working for me.

Here is the end result of the command in the RPG.
STRQMQRY QMQRY(qry1) OUTPUT(*OUTFILE) OUTFILE(QTEMP/myfile) SETVAR((Q &#039;&#039;&#039;&#039;) (COMPANY 1  ) (FROMDATE 19400101) (TODATE 20391231) (EXCLUDES &#039;(&#039;&#039;A&#039;&#039;,&#039;&#039;P&#039;&#039;,&#039;&#039;B&#039;&#039;)&#039;))

My message
Token A was not valid. Valid tokens: FOR WITH FETCH ORDER UNION OPTIMIZE.
RUN QUERY command failed with SQLCODE -104.                              
RUN QUERY command ended due to error.                                    
STRQMQRY command failed.    

I get the same just typing the command on the command line.     

Instead of this, Is there maybe another way to accomplish the same thing inside the QM?

Thanks for the help.]]></description>
		<content:encoded><![CDATA[<p>Tom,<br />
Still is not working for me.</p>
<p>Here is the end result of the command in the RPG.<br />
STRQMQRY QMQRY(qry1) OUTPUT(*OUTFILE) OUTFILE(QTEMP/myfile) SETVAR((Q &#8221;&#8221;) (COMPANY 1  ) (FROMDATE 19400101) (TODATE 20391231) (EXCLUDES &#8216;(&#8221;A&#8221;,&#8221;P&#8221;,&#8221;B&#8221;)&#8217;))</p>
<p>My message<br />
Token A was not valid. Valid tokens: FOR WITH FETCH ORDER UNION OPTIMIZE.<br />
RUN QUERY command failed with SQLCODE -104.<br />
RUN QUERY command ended due to error.<br />
STRQMQRY command failed.    </p>
<p>I get the same just typing the command on the command line.     </p>
<p>Instead of this, Is there maybe another way to accomplish the same thing inside the QM?</p>
<p>Thanks for the help.</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.048 seconds using memcached
Object Caching 393/399 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-24 17:48:50 -->