|
Loyd, Vern, I'm sure this may be syntax you're familiar with, but as an SQL neophyte, I have no idea what's going on here. 1) Looking at the SQL reference, the syntax for CAST is not quite concise. Is your usage of it used to force "columnized" output? 2) Your SQL example uses literals. Can you restate the example using field names from a database file? For this example, use: Field: AAA1 defined as 4A Field: BBB2 defined as 8,2S Field: CCC3 defined as 20A 3) Using RUNSQLSTM, how do I specify to which file the output should go? --- "Goodbar, Loyd (AFS-Water Valley)" <LGoodbar@afs.bwauto.com> wrote: > Dan... > > Thanks, Vern. The revised SQL looks like this: > > select > /* first part */ > cast('AAAA' as char(4)) concat > /* numeric part, right justify with floating left - sign */ > substr(cast(' ' as char(11)),1,11-length(strip(cast(char(-11.23) > as char(11)),b,' '))) concat strip(cast(char(-11.23) as > char(11)),b,' ') concat > /* text */ > cast('Some text' as char(20)) concat > /* CRLF */ > x'0d25' > from QSYS2/QSQPTABL > > With a result of > > AAAA -11.23Some text <crlf> > > Where "11" is the assumed field length based on the file sample, and > "-11.23" is the field name for the numeric data. > > If the file is similar to the sample provided, you can do this with > RUNSQLSTM or the QM Query equivalent, then do a CPYTOSTMF. > > HTH, > Loyd > > > -----Original Message----- > From: Vern Hamberg [mailto:vhamberg@centerfieldtechnology.com] > Sent: Wednesday, November 06, 2002 12:07 PM > To: midrange-l@midrange.com > Subject: RE: AS/400 app FTPs file to IFS??? > > > Loyd > > You can right-justify (generally) by > > substr(cast(' ' as char(n)), 1, n - length(strip(fieldname,b,' ')) || > strip(fieldname,b,' ') > > where "fieldname" could also be "char(numericfieldname)" or any other > expression that yields a string. __________________________________________________ Do you Yahoo!? HotJobs - Search new jobs daily now http://hotjobs.yahoo.com/
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.