Unfortunately the SQL CHAR() function does not have a parameter for
including an EDTWRD nor EDTCDE, nor do either such SQL functions exist
by name, as an extension to CHAR(). I still do not recall anyone ever
having submitted a design change request asking for those.
Query/400 and QM both offer some editing choices, and at least
Query/400 honors the editing defined in the file. Note: Query/400 is
the report writer for the interactive STRSQL, for local database access.
Pure SQL interfaces will offer no editing, and few if any report
writers built on SQL will offer the ability to get and use the editing
from the file; typically only offering application specified editing
options.
The functions of EDTWRD and EDTCDE are an implicit cast to character;
i.e. they are applied against numeric to produce a character string of
digits /edited/ in the desired format. Thus if the SQL CAST(), CHAR(),
or DIGITS() is used to cast the numeric to character, then there would
no longer be a need for the editing functions <even if they did exist>
because the data is already in character. Thus after casting, just
assemble the parts in SUBSTR(), TRIM(), CONCAT, RIGHT, etc. as necessary
to generate the desired format.
What editing was desired, was left unstated, but perhaps something
like the original editing where EDTWRD('0 & - - ') defines the
desired outcome [such that a leading zero is included], for which
possibly the following would suffice:
select
substr(digits(cust), 1, 1)
concat ' ' concat substr(digits(cust), 2, 3)
concat '-' concat substr(digits(cust), 5, 2) concat('-')
concat substr(digits(cust), 7, 4) as CUST
from masterfile
Regards, Chuck
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.