× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello all,

Maybe it's something that I just can't see...
I've created a CTE that looks at multiple fields in a record
and works correctly using interactive SQL.
When I code in ILE I don't get any results and
I'm thinking I'm not seeing something obvious.
The following works interactively providing me a single
total for the given item:
------------
with column(total) as
(select spqty1 from spfs where spitm1 = 836890
union all
select spqty2 from spfs where spitm2 = 836890
union all
select spqty3 from spfs where spitm3 = 836890
union all
select spqty4 from spfs where spitm4 = 836890
union all
select spqty5 from spfs where spitm5 = 836890)
select sum(total) from column

My ILE code doesn't work:
strsql = 'with column(total) as +
(select spqty1 from spfs where spitm1 = ? +
union all +
select spqty2 from spfs where spitm2 = ? +
union all +
select spqty3 from spfs where spitm3 = ? +
union all +
select spqty4 from spfs where spitm4 = ? +
union all +
select spqty5 from spfs where spitm5 = ?) +
select sum(total) from column';
exec sql Prepare sel from :strsql;
exec sql Declare Cur CURSOR for sel;
exec sql Open Cur using :fxitem, :fxitem, :fxitem, :fxitem,
:fxitem;

exec sql fetch Cur into :gross :NullInds;

Any suggestions would be appreciated.




"CONFIDENTIALITY NOTICE: This e-mail transmission (and/or the attachments accompanying it) contain confidential information belonging to the sender. The information is intended only for the use of the intended recipient. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or the taking of any action in reliance on the contents of the information is strictly prohibited. Any unauthorized interception of this transmission is illegal under the law. If you have received this transmission in error, please promptly notify the sender by reply e-mail, and then destroy all copies of the transmission."

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.