<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hi Frank:<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PowerHouse needs to pad out to the size of the column in the IN predicate otherwise&nbsp; you<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; would not get a match.<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I think you need multiple&nbsp;HOST variables&nbsp;to do what you want.<BR>
&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT face="Courier New">CURSOR product IN lilybase &nbsp;&amp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR><FONT size=2><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHERE (product.prod_code IN (:FIRST , :SECOIND, :THIRD, :FORTH&nbsp;) &amp;&nbsp;&nbsp;</TT></FONT></FONT>&nbsp;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT face="Courier New">FIRST , SECOIND, THIRD, FORTH&nbsp;</FONT>&nbsp;&nbsp;etc represent one value to included<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; in the IN predicate.<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp; Regards,<BR>
&nbsp;&nbsp;&nbsp;&nbsp; Peer Bateman&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>
&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR><BR><BR>
<BLOCKQUOTE>
<HR>
To: powerh-l@lists.sowder.com<BR>Subject: Cursor with WHERE . . IN<BR>From: Frank.Huizinga@eu.averydennison.com<BR>Date: Fri, 4 Apr 2008 10:26:21 +0200<BR><BR><BR><FONT face=sans-serif size=2>Hi All,</FONT> <BR><BR><FONT face=sans-serif size=2>I'm facing a problem with using embedded SQL WHERE .. IN</FONT> <BR><BR><FONT face=sans-serif size=2>When I'm only selecting one product it works fine (although I should than use WHERE . . =)</FONT> <BR><FONT face=sans-serif size=2>When I want to retrieve multiple products it fails. The examples below explains what is happening in the background. Has any one a solution to this?</FONT> <BR><BR><FONT face=sans-serif size=2>Selecting one product:</FONT> <BR><BR><FONT size=2><TT>SCREEN in &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>SET LIST SQL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </TT></FONT><BR><FONT size=2><TT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>TEMPORARY t_prod_array CHARACTER SIZE &nbsp;256 &amp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </TT></FONT><BR><FONT size=2><TT>&nbsp; INITIAL "DA7022000"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT></FONT><BR><FONT size=2><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT></FONT>&nbsp;<BR><FONT size=2><TT>&nbsp;&nbsp;&nbsp;CURSOR product IN lilybase &nbsp;&amp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR><FONT size=2><TT>&nbsp; WHERE (product.prod_code IN (:TRUNC(t_prod_array))) &amp;&nbsp;&nbsp;</TT></FONT><FONT face=Verdana>&nbsp;</FONT><BR>&nbsp;&nbsp;PRIMARY KEY prod_code OCCURS 5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>SKIP TO 3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>ALIGN (1,,4) (,,30) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>CLUSTER OCCURS WITH qad_product &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>FIELD prod_code DISPLAY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>FIELD prod_desc1 DISPLAY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </TT></FONT><BR><FONT size=2><TT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>BUILD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><BR><FONT face=sans-serif size=2>Resulting DMAPIFIL content:</FONT> <BR><BR><FONT size=2><TT>prepare r1 from </TT></FONT><BR><FONT size=2><TT>"SELECT * FROM LILY.PRODUCT &nbsp;where PRODUCT.PROD_CODE IN (:phE1 )"</TT></FONT> <BR><FONT size=2><TT>&nbsp;in t1;</TT></FONT> <BR><FONT size=2><TT>describe input r1;</TT></FONT> <BR><FONT size=2><TT>declare c1 cursor for r1 read write, keep;</TT></FONT> <BR><FONT color=blue size=2><TT>open c1 parm phE1:"DA7022000 &nbsp; &nbsp; &nbsp; &nbsp; ";</TT></FONT> <BR><BR><FONT face=sans-serif size=2>The phE1 variable is padded with blanks to the size of prod_code CHAR(18)</FONT> <BR><FONT face=sans-serif size=2>but the record is retieved.</FONT> <BR><BR><BR><FONT face=sans-serif size=2>Selection of multiple products</FONT> <BR><BR><FONT size=2><TT>SCREEN in &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>SET LIST SQL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </TT></FONT><BR><FONT size=2><TT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>TEMPORARY t_prod_array CHARACTER SIZE &nbsp;256 &amp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </TT></FONT><BR><FONT size=2><TT>&nbsp; INITIAL "DA7022000,DA7021980" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>CURSOR product IN lilybase &nbsp;&amp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </TT></FONT><BR><FONT size=2><TT>&nbsp; WHERE (product.prod_code IN (:TRUNC(t_prod_array))) &amp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>&nbsp; &nbsp; &nbsp;PRIMARY KEY prod_code OCCURS 5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>SKIP TO 3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>ALIGN (1,,4) (,,30) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>CLUSTER OCCURS WITH product &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>FIELD prod_code DISPLAY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>FIELD prod_desc1 DISPLAY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </TT></FONT><BR><FONT size=2><TT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><FONT size=2><TT>BUILD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</TT></FONT> <BR><BR><FONT face=sans-serif size=2>Resulting DMAPIFIL content:</FONT> <BR><BR><FONT size=2><TT>prepare r1 from </TT></FONT><BR><FONT size=2><TT>"select * from LILY.PRODUCT where PRODUCT.PROD_CODE IN (:phE1 )"</TT></FONT> <BR><FONT size=2><TT>&nbsp;in t1;</TT></FONT> <BR><FONT size=2><TT>describe input r1;</TT></FONT> <BR><FONT size=2><TT>declare c1 cursor for r1 read write, keep;</TT></FONT> <BR><FONT size=2><TT>open c1 parm phE1:"DA7022000,DA702198";</TT></FONT> <BR><BR><FONT face=sans-serif size=2>The phe1 parameter is truncated to the size of the attribute prod_code which is CHAR(18)</FONT> <BR><FONT face=sans-serif size=2>and 'No records found matching . . ' is issued</FONT> <BR><BR><BR><FONT face=sans-serif size=2>Thanks in advance</FONT> <BR><BR><FONT face=sans-serif size=2>Best regards,<BR><BR>Frank<BR></FONT><BR>- -----------------------------------------------------------------<BR>The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.<BR></BLOCKQUOTE><br /><hr />You could win $1000 a day, now until May 12th, just for signing in to Windows Live Messenger. <a href='http://g.msn.ca/ca55/211' target='_new'>Check out SignInAndWIN.ca to learn more!</a></body>
</html>