<br><font size=2 face="sans-serif">Hi All,</font>
<br>
<br><font size=2 face="sans-serif">I'm facing a problem with using embedded
SQL WHERE .. IN</font>
<br>
<br><font size=2 face="sans-serif">When I'm only selecting one product
it works fine (although I should than use WHERE . . =)</font>
<br><font size=2 face="sans-serif">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 size=2 face="sans-serif">Selecting one product:</font>
<br>
<br><font size=2><tt>SCREEN in
</tt></font>
<br><font size=2><tt>SET LIST SQL
</tt></font>
<br><font size=2><tt>
</tt></font>
<br><font size=2><tt>TEMPORARY t_prod_array CHARACTER SIZE 256 &
</tt></font>
<br><font size=2><tt> INITIAL "DA7022000"
</tt></font>
<br><font size=2><tt>
</tt></font>
<br><font size=2><tt>CURSOR product IN lilybase &
</tt></font>
<br><font size=2><tt> WHERE (product.prod_code IN (:TRUNC(t_prod_array)))
& </tt></font>
<br><font size=2><tt> PRIMARY KEY prod_code OCCURS 5
</tt></font>
<br><font size=2><tt>
</tt></font>
<br><font size=2><tt>SKIP TO 3
</tt></font>
<br><font size=2><tt>
</tt></font>
<br><font size=2><tt>ALIGN (1,,4) (,,30)
</tt></font>
<br><font size=2><tt>CLUSTER OCCURS WITH qad_product
</tt></font>
<br><font size=2><tt>FIELD prod_code DISPLAY
</tt></font>
<br><font size=2><tt>FIELD prod_desc1 DISPLAY
</tt></font>
<br><font size=2><tt>
</tt></font>
<br><font size=2><tt>BUILD
</tt></font>
<br>
<br><font size=2 face="sans-serif">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> 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 color=blue><tt>open c1 parm phE1:"DA7022000
";</tt></font>
<br>
<br><font size=2 face="sans-serif">The phE1 variable is padded with blanks
to the size of prod_code CHAR(18)</font>
<br><font size=2 face="sans-serif">but the record is retieved.</font>
<br>
<br>
<br><font size=2 face="sans-serif">Selection of multiple products</font>
<br>
<br><font size=2><tt>SCREEN in
</tt></font>
<br><font size=2><tt>SET LIST SQL
</tt></font>
<br><font size=2><tt>
</tt></font>
<br><font size=2><tt>TEMPORARY t_prod_array CHARACTER SIZE 256 &
</tt></font>
<br><font size=2><tt> INITIAL "DA7022000,DA7021980"
</tt></font>
<br><font size=2><tt>
</tt></font>
<br><font size=2><tt>CURSOR product IN lilybase &
</tt></font>
<br><font size=2><tt> WHERE (product.prod_code IN (:TRUNC(t_prod_array)))
& </tt></font>
<br><font size=2><tt> PRIMARY KEY prod_code OCCURS 5
</tt></font>
<br><font size=2><tt>
</tt></font>
<br><font size=2><tt>SKIP TO 3
</tt></font>
<br><font size=2><tt>
</tt></font>
<br><font size=2><tt>ALIGN (1,,4) (,,30)
</tt></font>
<br><font size=2><tt>CLUSTER OCCURS WITH product
</tt></font>
<br><font size=2><tt>FIELD prod_code DISPLAY
</tt></font>
<br><font size=2><tt>FIELD prod_desc1 DISPLAY
</tt></font>
<br><font size=2><tt>
</tt></font>
<br><font size=2><tt>BUILD
</tt></font>
<br>
<br><font size=2 face="sans-serif">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> 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 size=2 face="sans-serif">The phe1 parameter is truncated to the
size of the attribute prod_code which is CHAR(18)</font>
<br><font size=2 face="sans-serif">and 'No records found matching . . '
is issued</font>
<br>
<br>
<br><font size=2 face="sans-serif">Thanks in advance</font>
<br>
<br><font size=2 face="sans-serif">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>