× 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.



I probably ask more SQL how-to questions here than everyone else combined,
so I had to tell you I figured out a relatively complex one (at least for
me) by myself.

I need to set up a transaction file that's going to be FTPed to another
company. I started writing a cursor driven SQLRPG program because the data
to be gathered needed to come from 4 different files, and the fields
massaged somewhat. Then I remembered someone (Charles Wilt?) saying that if
you were using a cursor in SQL, you were probably doing something wrong. So
I stopped and pondered for a while. Then I came up with this (below) and it
works!

Exec SQL Insert into INSTLTRN
(Select :RptDate,
c.DCNBR,
s.CUSNR,
s.INVNRP,
s.INVDT,
c.INVTRNCD,
s.QTYSH,
Case S.UNITS
When 'U' Then i.QSUN2
Else i.QSUN1
End As QTYUOM,
0,
s.ITNSA/s.QTYSH,
s.ITNSA,
s.ITNBR,
i.ITDSC,
i.PACKX,
i.SIZEX,
i.BRAND,
v.VNDNM,
i.VNITM,
Cast(i.ADUNQ As Char(1)) ConCat
Cast(i.VUPCD As Char(5)) ConCat
Cast(i.IUPCD As Char(5)),
0,
c.PRGCODE
From SAHISTW S
Join INSTLCTL c
On '1' = c.KEYID
Join DMITMMST I
On s.ITNBR = i.ITNBR
Join DMVDRMST V
On s.VNDNR = v.VNDNR
Where s.VNDNR = c.vndnr and
s.INVDT >= :BgnSlsDate and
s.INVDT <= :EndSlsDate and
s.QTYSH > 0);

Host variables and all. And it runs fast.

I get an extra beer tonight.


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.