 




<?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: Query Variables in CL</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/query-variables-in-cl/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/query-variables-in-cl/</link>
	<description></description>
	<lastBuildDate>Sat, 25 May 2013 11:47:02 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/query-variables-in-cl/#comment-70854</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Wed, 25 Nov 2009 03:54:37 +0000</pubDate>
		<guid isPermaLink="false">#comment-70854</guid>
		<description><![CDATA[Hmmm... this &quot;answer&quot; editor doesn&#039;t like four single-quotes in a row. It changed them into two double-quotes. Well, if what I said made sense, you&#039;ll figure it out.

Tom]]></description>
		<content:encoded><![CDATA[<p>Hmmm&#8230; this &#8220;answer&#8221; editor doesn&#8217;t like four single-quotes in a row. It changed them into two double-quotes. Well, if what I said made sense, you&#8217;ll figure it out.</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/query-variables-in-cl/#comment-70853</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Wed, 25 Nov 2009 03:52:32 +0000</pubDate>
		<guid isPermaLink="false">#comment-70853</guid>
		<description><![CDATA[BTW, to add quotes, use a QM query like:&lt;pre&gt;select col1,col2 from myfile where col1 like &amp;Q&amp;PARM&amp;Q&lt;/pre&gt;Then in the CL:&lt;pre&gt;STRQMQRY QMQRY(myqry) SETVAR(  ( Q &#039;&#039;&#039;&#039; ) (PARM &amp;CLvar)  )&lt;/pre&gt;The &amp;Q query substitution variable receives a single quote as its value. You can re-use it wherever needed in the query statement.

No need to add the quotes in CL. Let QM query do it for you. Just tell it where.

Tom]]></description>
		<content:encoded><![CDATA[<p>BTW, to add quotes, use a QM query like:
<pre>select col1,col2 from myfile where col1 like &amp;Q&amp;PARM&amp;Q</pre>
<p>Then in the CL:
<pre>STRQMQRY QMQRY(myqry) SETVAR(  ( Q '''' ) (PARM &amp;CLvar)  )</pre>
<p>The &amp;Q query substitution variable receives a single quote as its value. You can re-use it wherever needed in the query statement.</p>
<p>No need to add the quotes in CL. Let QM query do it for you. Just tell it where.</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/query-variables-in-cl/#comment-70852</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Wed, 25 Nov 2009 03:41:20 +0000</pubDate>
		<guid isPermaLink="false">#comment-70852</guid>
		<description><![CDATA[From what you asked, it&#039;s a CHAR column that contains &#039;9000%&#039; as a possible value. When 9000 is input, you want to retrieve the &#039;9000%&#039; value. If that&#039;s true, there shouldn&#039;t be any problem.

The numeric 9000 is going to be a character literal when it gets into the QM query statement. You just need to ensure that quotes get placed in the proper positions and that the &quot;%&quot; wild-card also gets included.

Tom]]></description>
		<content:encoded><![CDATA[<p>From what you asked, it&#8217;s a CHAR column that contains &#8217;9000%&#8217; as a possible value. When 9000 is input, you want to retrieve the &#8217;9000%&#8217; value. If that&#8217;s true, there shouldn&#8217;t be any problem.</p>
<p>The numeric 9000 is going to be a character literal when it gets into the QM query statement. You just need to ensure that quotes get placed in the proper positions and that the &#8220;%&#8221; wild-card also gets included.</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kumari</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/query-variables-in-cl/#comment-45037</link>
		<dc:creator>kumari</dc:creator>
		<pubDate>Mon, 30 Jan 2006 08:26:13 +0000</pubDate>
		<guid isPermaLink="false">#comment-45037</guid>
		<description><![CDATA[I think this will solve your problem -

OPNQRYF FILE((FILENAME))QRYSLT(FIELDNAME *EQ %WLDCRD(9000*)

Please let me know, this solved your problem or how else did you solve it. ]]></description>
		<content:encoded><![CDATA[<p>I think this will solve your problem -</p>
<p>OPNQRYF FILE((FILENAME))QRYSLT(FIELDNAME *EQ %WLDCRD(9000*)</p>
<p>Please let me know, this solved your problem or how else did you solve it. </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jplamontre</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/query-variables-in-cl/#comment-45038</link>
		<dc:creator>jplamontre</dc:creator>
		<pubDate>Sun, 29 Jan 2006 15:52:02 +0000</pubDate>
		<guid isPermaLink="false">#comment-45038</guid>
		<description><![CDATA[some notes to have in mind :
-1- a variable transmitted to a qmqry is up to 55 chars.
-2- a variable in a query can not be in a litteral (between quotes)

wrong : select ... like &#039;&amp;P1&#039;...
correct : select ... like &amp;P1...

this means you have to add quotes yourself in the cl :
dcl &amp;quote *char 1 value(&#039;&#039;&#039;&#039;)
dcl &amp;param ...
dcl &amp;paramquoted ... len is len of &amp;param + 2

chgvar &amp;paramquoted (&amp;quote *cat &amp;param *cat &amp;quote)
strqmqry ... setvar ((P1 &amp;paramquoted))

if qmqry has too much limitations for your job, you can easily replace it by executesql or execsql, two tools at http://jplamontre.free.fr/jpltools]]></description>
		<content:encoded><![CDATA[<p>some notes to have in mind :<br />
-1- a variable transmitted to a qmqry is up to 55 chars.<br />
-2- a variable in a query can not be in a litteral (between quotes)</p>
<p>wrong : select &#8230; like &#8216;&amp;P1&#8242;&#8230;<br />
correct : select &#8230; like &amp;P1&#8230;</p>
<p>this means you have to add quotes yourself in the cl :<br />
dcl &amp;quote *char 1 value(&#8221;&#8221;)<br />
dcl &amp;param &#8230;<br />
dcl &amp;paramquoted &#8230; len is len of &amp;param + 2</p>
<p>chgvar &amp;paramquoted (&amp;quote *cat &amp;param *cat &amp;quote)<br />
strqmqry &#8230; setvar ((P1 &amp;paramquoted))</p>
<p>if qmqry has too much limitations for your job, you can easily replace it by executesql or execsql, two tools at <a href="http://jplamontre.free.fr/jpltools" rel="nofollow">http://jplamontre.free.fr/jpltools</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: astradyne</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/query-variables-in-cl/#comment-45039</link>
		<dc:creator>astradyne</dc:creator>
		<pubDate>Fri, 27 Jan 2006 04:57:36 +0000</pubDate>
		<guid isPermaLink="false">#comment-45039</guid>
		<description><![CDATA[Hi Samantha

In the past when I&#039;ve wanted to do this I&#039;ve gone down the route of creating a Query/400 query and then using the RTVQMQRY route to convert it so that it can use parameters.

There are lots of articles on this process, just Google RTVQMQRY or visit http://search400.techtarget.com/tip/1,289483,sid3_gci530291,00.html for an exmple of how to use it.

All the best

Jonathan]]></description>
		<content:encoded><![CDATA[<p>Hi Samantha</p>
<p>In the past when I&#8217;ve wanted to do this I&#8217;ve gone down the route of creating a Query/400 query and then using the RTVQMQRY route to convert it so that it can use parameters.</p>
<p>There are lots of articles on this process, just Google RTVQMQRY or visit <a href="http://search400.techtarget.com/tip/1,289483,sid3_gci530291,00.html" rel="nofollow">http://search400.techtarget.com/tip/1,289483,sid3_gci530291,00.html</a> for an exmple of how to use it.</p>
<p>All the best</p>
<p>Jonathan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chuckm</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/query-variables-in-cl/#comment-45040</link>
		<dc:creator>chuckm</dc:creator>
		<pubDate>Thu, 26 Jan 2006 18:15:15 +0000</pubDate>
		<guid isPermaLink="false">#comment-45040</guid>
		<description><![CDATA[Sorry...finger check.

As I was trying to say, you have to create a text string that contains the query statment with the contents of your variable concatenated within.  See if this little example doesn&#039;t get you going:

PGM                                                                    
DCL        VAR(&amp;PART1) TYPE(*CHAR) LEN(80) +                           
             VALUE(&#039;Select A B C D from lib/file where A IS LIKE &quot;&#039;)   
DCL        VAR(&amp;VARIABLE) TYPE(*CHAR) LEN(10) VALUE(&#039;9000&#039;)            
DCL        VAR(&amp;PART2) TYPE(*CHAR) LEN(80) VALUE(&#039;%&quot; Order BY A B C D&#039;)
DCL        VAR(&amp;QRYSTMT) TYPE(*CHAR) LEN(200)                          
CHGVAR     VAR(&amp;QRYSTMT) VALUE(&amp;PART1 &#124;]]></description>
		<content:encoded><![CDATA[<p>Sorry&#8230;finger check.</p>
<p>As I was trying to say, you have to create a text string that contains the query statment with the contents of your variable concatenated within.  See if this little example doesn&#8217;t get you going:</p>
<p>PGM<br />
DCL        VAR(&amp;PART1) TYPE(*CHAR) LEN(80) +<br />
             VALUE(&#8216;Select A B C D from lib/file where A IS LIKE &#8220;&#8216;)<br />
DCL        VAR(&amp;VARIABLE) TYPE(*CHAR) LEN(10) VALUE(&#8217;9000&#8242;)<br />
DCL        VAR(&amp;PART2) TYPE(*CHAR) LEN(80) VALUE(&#8216;%&#8221; Order BY A B C D&#8217;)<br />
DCL        VAR(&amp;QRYSTMT) TYPE(*CHAR) LEN(200)<br />
CHGVAR     VAR(&amp;QRYSTMT) VALUE(&amp;PART1 |</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chuckm</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/query-variables-in-cl/#comment-45041</link>
		<dc:creator>chuckm</dc:creator>
		<pubDate>Thu, 26 Jan 2006 17:59:57 +0000</pubDate>
		<guid isPermaLink="false">#comment-45041</guid>
		<description><![CDATA[SamanthaD,  In general, when you want to pass a variable into a query statement, you make the entire statement a text string and concatenate the value of the variable into it.

Here&#039;s a little example that may get you going:
 PGM                                                        DCL  VAR(&amp;PART1) TYPE(*CHAR) LEN(80) + 
VALUE(&#039;Select A B C D from lib/file where A IS LIKE &quot;&#039;)      
DCL        VAR(&amp;VARIABLE) TYPE(*CHAR) LEN(10) VALUE(&#039;9000&#039;)               
DCL        VAR(&amp;PART2) TYPE(*CHAR) LEN(80) VALUE(&#039;%&quot; Order BY A B C D&#039;)   
DCL        VAR(&amp;QRYSTMT) TYPE(*CHAR) LEN(200)                             
                                                                          
CHGVAR     VAR(&amp;QRYSTMT) VALUE(&amp;PART1 &#124;]]></description>
		<content:encoded><![CDATA[<p>SamanthaD,  In general, when you want to pass a variable into a query statement, you make the entire statement a text string and concatenate the value of the variable into it.</p>
<p>Here&#8217;s a little example that may get you going:<br />
 PGM                                                        DCL  VAR(&amp;PART1) TYPE(*CHAR) LEN(80) +<br />
VALUE(&#8216;Select A B C D from lib/file where A IS LIKE &#8220;&#8216;)<br />
DCL        VAR(&amp;VARIABLE) TYPE(*CHAR) LEN(10) VALUE(&#8217;9000&#8242;)<br />
DCL        VAR(&amp;PART2) TYPE(*CHAR) LEN(80) VALUE(&#8216;%&#8221; Order BY A B C D&#8217;)<br />
DCL        VAR(&amp;QRYSTMT) TYPE(*CHAR) LEN(200)                             </p>
<p>CHGVAR     VAR(&amp;QRYSTMT) VALUE(&amp;PART1 |</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sheldonlinker</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/query-variables-in-cl/#comment-45042</link>
		<dc:creator>sheldonlinker</dc:creator>
		<pubDate>Thu, 26 Jan 2006 15:05:59 +0000</pubDate>
		<guid isPermaLink="false">#comment-45042</guid>
		<description><![CDATA[First, regaring LIKE and numeric data:  It won&#039;t work.  Perhaps if what you have is a number, then what you want is

          VARCHAR(field) LIKE VARCHAR(argument)&#124;&#124;&#039;%&#039;

Second, there are certain restrictions when coding SQL from CL.  I find it easier to write a C/SQL (any other language/SQL) command, and call it from CL.  Inside such a program, the line above will have an added variable marker:

          VARCHAR(field) LIKE VARCHAR(:argument)&#124;&#124;&#039;%&#039;]]></description>
		<content:encoded><![CDATA[<p>First, regaring LIKE and numeric data:  It won&#8217;t work.  Perhaps if what you have is a number, then what you want is</p>
<p>          VARCHAR(field) LIKE VARCHAR(argument)||&#8217;%&#8217;</p>
<p>Second, there are certain restrictions when coding SQL from CL.  I find it easier to write a C/SQL (any other language/SQL) command, and call it from CL.  Inside such a program, the line above will have an added variable marker:</p>
<p>          VARCHAR(field) LIKE VARCHAR(:argument)||&#8217;%&#8217;</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.017 seconds using memcached
Object Caching 380/383 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-25 12:56:13 -->