 




<?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: passing variable in CL Program using QMQRY and SQL</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/passing-variable-in-cl-program-using-qmqry-and-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/passing-variable-in-cl-program-using-qmqry-and-sql/</link>
	<description></description>
	<lastBuildDate>Mon, 20 May 2013 05:26:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/passing-variable-in-cl-program-using-qmqry-and-sql/#comment-81506</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Tue, 14 Sep 2010 23:03:12 +0000</pubDate>
		<guid isPermaLink="false">#comment-81506</guid>
		<description><![CDATA[BTW, this editor (and perhaps some browser features) doesn&#039;t always handle single-quotes and double-quotes correctly. The example code should show four consecutive single-quote marks. However, sometimes are are incorrectly shown as two double-quote marks.

Take care when trying to understand how four single-quote marks work.

Tom]]></description>
		<content:encoded><![CDATA[<p>BTW, this editor (and perhaps some browser features) doesn&#8217;t always handle single-quotes and double-quotes correctly. The example code should show four consecutive single-quote marks. However, sometimes are are incorrectly shown as two double-quote marks.</p>
<p>Take care when trying to understand how four single-quote marks work.</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/passing-variable-in-cl-program-using-qmqry-and-sql/#comment-81503</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Tue, 14 Sep 2010 21:32:17 +0000</pubDate>
		<guid isPermaLink="false">#comment-81503</guid>
		<description><![CDATA[&lt;i&gt;However I modified it exactly how you show it and I get ‘Column MISBXG not in specified tables.’ which is what I’ve been getting all along.&lt;/i&gt;

Since I don&#039;t see a reference to &quot;MISBXG&quot; in your code, I assume that it arises from this:

&lt;i&gt;Your statement of “DELETE FROM mylib/myfile WHERE myfile = &amp;USER” I had tried before.&lt;/i&gt;

It&#039;s almost certain that that won&#039;t work, if I understand what you want. The purpose of the example was to demonstrate what happens when the quotes are left off of the statement. The result is that the value of &amp;USER is inserted into the statement without any quotes. SQL will then interpret the value as the name of a column. So, if you pass &quot;MISBXG&quot; in for &amp;USER, SQL will expect to find a column named MISBXG.

So, you should see that:&lt;ol&gt;
	&lt;li&gt;You can&#039;t have quotes around a replacement variable as part of the compiled statement.&lt;/li&gt;&lt;li&gt;And you can&#039;t let the statement run without any quotes when the replacement variable represents a character.&lt;/li&gt;
&lt;/ol&gt;
Since neither of those two alternatives will work, you must use a third alternative.

If the quotes can&#039;t be there when you compile the QM query and if the quotes must be there before the SQL statement executes, the only reasonable third alternative is to &lt;i&gt;add the quotes at run-time&lt;/i&gt;.

You can add them to the character value that you pass in to the &amp;USER variable or you can pass in an extra replacement variable that will carry the quote mark.

To stop prompting for a replacement variable, you need to pass the variable into the SETVAR() parameter. I showed one way to do that:&lt;pre&gt;
 STRQMQRY   QMQRY(REVEALDLT)
            SETVAR((USER &amp;USER) ( &#039;q&#039;  &#039;&#039;&#039;&#039; )&lt;/pre&gt;
The &amp;q variable is referenced in the SETVAR() parameter. But notice that it is a lower-case &quot;q&quot;. You don&#039;t have to use a lower-case &quot;q&quot;. You can use an upper-case &quot;Q&quot; or any other valid name.

If you use a lower-case replacement variable name in the SQL statement, you must pass a lower-case name into the SETVAR() parameter. If you look at the SETVAR() parameter, you should see that the name is quoted. That keeps it as a lower-case letter.

It was an example:&lt;pre&gt;
DELETE FROM mylib/myfile WHERE myfile = &amp;q&amp;USER&amp;q&lt;/pre&gt;
The SQL statement has the name &quot;&amp;q&quot; as a lower-case name. The name in the SETVAR() parameter must be &lt;b&gt;exactly&lt;/b&gt; the same. If you use a lower-case name in the SQL statement, you must pass a lower-case name into the SETVAR() parameter.

You could use an upper-case name:&lt;pre&gt;
DELETE FROM mylib/myfile WHERE myfile = &amp;Q&amp;USER&amp;Q&lt;/pre&gt;
Then you would call the statement like this:&lt;pre&gt;
 STRQMQRY   QMQRY(REVEALDLT)
            SETVAR((USER &amp;USER) ( Q  &#039;&#039;&#039;&#039; )&lt;/pre&gt;
Or this would also result in an upper-case name:&lt;pre&gt;
 STRQMQRY   QMQRY(REVEALDLT)
            SETVAR((USER &amp;USER) ( q  &#039;&#039;&#039;&#039; )&lt;/pre&gt;
Since there are no quote marks around the &quot;q&quot;, it will automatically be upper-cased.

I can&#039;t be certain what is causing the prompting in your program because you didn&#039;t show your new CL nor your new SQL statement. But I&#039;d guess it&#039;s because you have one of them as upper-case and the other as lower-case.

Tom]]></description>
		<content:encoded><![CDATA[<p><i>However I modified it exactly how you show it and I get ‘Column MISBXG not in specified tables.’ which is what I’ve been getting all along.</i></p>
<p>Since I don&#8217;t see a reference to &#8220;MISBXG&#8221; in your code, I assume that it arises from this:</p>
<p><i>Your statement of “DELETE FROM mylib/myfile WHERE myfile = &amp;USER” I had tried before.</i></p>
<p>It&#8217;s almost certain that that won&#8217;t work, if I understand what you want. The purpose of the example was to demonstrate what happens when the quotes are left off of the statement. The result is that the value of &amp;USER is inserted into the statement without any quotes. SQL will then interpret the value as the name of a column. So, if you pass &#8220;MISBXG&#8221; in for &amp;USER, SQL will expect to find a column named MISBXG.</p>
<p>So, you should see that:
<ol>
<li>You can&#8217;t have quotes around a replacement variable as part of the compiled statement.</li>
<li>And you can&#8217;t let the statement run without any quotes when the replacement variable represents a character.</li>
</ol>
<p>Since neither of those two alternatives will work, you must use a third alternative.</p>
<p>If the quotes can&#8217;t be there when you compile the QM query and if the quotes must be there before the SQL statement executes, the only reasonable third alternative is to <i>add the quotes at run-time</i>.</p>
<p>You can add them to the character value that you pass in to the &amp;USER variable or you can pass in an extra replacement variable that will carry the quote mark.</p>
<p>To stop prompting for a replacement variable, you need to pass the variable into the SETVAR() parameter. I showed one way to do that:
<pre>
 STRQMQRY   QMQRY(REVEALDLT)
            SETVAR((USER &amp;USER) ( 'q'  '''' )</pre>
<p>The &amp;q variable is referenced in the SETVAR() parameter. But notice that it is a lower-case &#8220;q&#8221;. You don&#8217;t have to use a lower-case &#8220;q&#8221;. You can use an upper-case &#8220;Q&#8221; or any other valid name.</p>
<p>If you use a lower-case replacement variable name in the SQL statement, you must pass a lower-case name into the SETVAR() parameter. If you look at the SETVAR() parameter, you should see that the name is quoted. That keeps it as a lower-case letter.</p>
<p>It was an example:
<pre>
DELETE FROM mylib/myfile WHERE myfile = &amp;q&amp;USER&amp;q</pre>
<p>The SQL statement has the name &#8220;&amp;q&#8221; as a lower-case name. The name in the SETVAR() parameter must be <b>exactly</b> the same. If you use a lower-case name in the SQL statement, you must pass a lower-case name into the SETVAR() parameter.</p>
<p>You could use an upper-case name:
<pre>
DELETE FROM mylib/myfile WHERE myfile = &amp;Q&amp;USER&amp;Q</pre>
<p>Then you would call the statement like this:
<pre>
 STRQMQRY   QMQRY(REVEALDLT)
            SETVAR((USER &amp;USER) ( Q  '''' )</pre>
<p>Or this would also result in an upper-case name:
<pre>
 STRQMQRY   QMQRY(REVEALDLT)
            SETVAR((USER &amp;USER) ( q  '''' )</pre>
<p>Since there are no quote marks around the &#8220;q&#8221;, it will automatically be upper-cased.</p>
<p>I can&#8217;t be certain what is causing the prompting in your program because you didn&#8217;t show your new CL nor your new SQL statement. But I&#8217;d guess it&#8217;s because you have one of them as upper-case and the other as lower-case.</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bggas400</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/passing-variable-in-cl-program-using-qmqry-and-sql/#comment-81501</link>
		<dc:creator>bggas400</dc:creator>
		<pubDate>Tue, 14 Sep 2010 19:57:35 +0000</pubDate>
		<guid isPermaLink="false">#comment-81501</guid>
		<description><![CDATA[Never mind Tom.  the &#039;q&#039; was capitalized &#039;Q&#039;.  It works fine now.  Thanks.
Barry]]></description>
		<content:encoded><![CDATA[<p>Never mind Tom.  the &#8216;q&#8217; was capitalized &#8216;Q&#8217;.  It works fine now.  Thanks.<br />
Barry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bggas400</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/passing-variable-in-cl-program-using-qmqry-and-sql/#comment-81500</link>
		<dc:creator>bggas400</dc:creator>
		<pubDate>Tue, 14 Sep 2010 19:41:53 +0000</pubDate>
		<guid isPermaLink="false">#comment-81500</guid>
		<description><![CDATA[Thanks Tom.

I had tried variations of your first option to no avail.  However I modified it exactly how you show it and I get ‘Column MISBXG not in specified tables.’ which is what I’ve been getting all along.

Your statement of “DELETE FROM mylib/myfile WHERE myfile = &amp;USER” I had tried before.


On your second option, I keep getting a prompt to “Type a value for variable &quot;q&quot; and press Enter.”
Once I input a ‘ quote, the record is deleted.
Now how do I get that to stop prompting?

Thanks,
Barry]]></description>
		<content:encoded><![CDATA[<p>Thanks Tom.</p>
<p>I had tried variations of your first option to no avail.  However I modified it exactly how you show it and I get ‘Column MISBXG not in specified tables.’ which is what I’ve been getting all along.</p>
<p>Your statement of “DELETE FROM mylib/myfile WHERE myfile = &amp;USER” I had tried before.</p>
<p>On your second option, I keep getting a prompt to “Type a value for variable &#8220;q&#8221; and press Enter.”<br />
Once I input a ‘ quote, the record is deleted.<br />
Now how do I get that to stop prompting?</p>
<p>Thanks,<br />
Barry</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.041 seconds using memcached
Object Caching 309/315 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-20 07:16:11 -->