>>Look into writing your own SQL registered function.

>Very interesting. I didn't know we could create UDF
>for use in SQL statements.  Does anyone have a link
>where it is explained how to create & register
>functions and where all this is documented ?

http://www.iseries400.ibm.com/infocenter  Choose the link on the left for
Database and File systems, then DB2 UDB for iSeries.  They've re-arranged
the page and it looks great!  Anyway, take a look at the SQL Programming
Concepts
http://publib.boulder.ibm.com/pubs/html/as400/v5r1/ic2924/info/sqlp/rbafymst
02.htm, specifically
http://publib.boulder.ibm.com/pubs/html/as400/v5r1/ic2924/info/sqlp/rbafymst
objudf.htm#HDROBJUDF.

>One thought though : We are still using RPG400 (or RPG
>III as you may want to call it) and not RPG IV i.e no
>D-specs, no %editc function etc...  Can we still
>create SQL UDF's here?

Well, if you have the RPG400 compiler, you have the RPG IV compiler too!
The example I posted should compile and run on your machine with no problem.
As far as I know, you should be able to write your UDF in RPG400 but there
are limitations, especially in the binary data type.

As for not having %editc et.al., you can use the edit APIs.  Here's an
ancient example:
I* Convert edit code parms
I           IDS
I                                        1 256 CMASK
I                                    B 257 2600CMLEN
I                                    B 261 2640CRLEN
I                                      265 265 CZFILL
I                                      266 266 CCODE
I                                      267 267 CFILL
I                                    B 268 2710CPREC
I                                    B 272 2750CDEC
I                                      276 371 CERROR
I* Edit parms
I           IDS
I                                        1  24 EOUTPT
I                                    B  25  280ERLEN
I                                       29  402EINPUT
I                                       41  50 EINTYP
I                                    B  51  540EPREC
I                                       55 310 EMASK
I                                    B 311 3140EMLEN
I                                      315 315 EZFILL
I                                      316 408 EERROR
I* Exception/error format
IERRFMT     IDS
I                                    B   1   40ERPRO
I                                    B   5   80ERAVL
I                                        9  15 ERID
I                                       16  96 ERDTA
C* Set up error structure
C                     Z-ADD96        ERPRO
C                     MOVELERRFMT    CERROR
C* Convert edit code to mask
C                     MOVE *BLANKS   CMASK     P
C                     MOVE 'J'       CCODE
C                     MOVE '$'       CFILL
C                     Z-ADD12        CPREC
C                     Z-ADD2         CDEC
C                     CALL 'QECCVTEC'
C                     PARM           CMASK
C                     PARM           CMLEN
C                     PARM           CRLEN
C                     PARM           CZFILL
C                     PARM           CCODE
C                     PARM           CFILL
C                     PARM           CPREC
C                     PARM           CDEC
C                     PARM           CERROR
C                     MOVELCERROR    ERRFMT
C* Set up error structure
C                     Z-ADD96        ERPRO
C                     MOVELERRFMT    EERROR
C* Edit input variable
C                     MOVE *BLANKS   EOUTPT
C                     Z-ADDCRLEN     ERLEN
C                     Z-ADD-123456.78EINPUT
C                     MOVEL'*ZONED'  EINTYP
C                     Z-ADDCPREC     EPREC
C                     MOVELCMASK     EMASK     P
C                     Z-ADDCMLEN     EMLEN
C                     MOVELCZFILL    EZFILL
C                     CALL 'QECEDT'
C                     PARM           EOUTPT
C                     PARM           ERLEN
C                     PARM           EINPUT
C                     PARM           EINTYP
C                     PARM           EPREC
C                     PARM           EMASK
C                     PARM           EMLEN
C                     PARM           EZFILL
C                     PARM           EERROR
C                     MOVELEERROR    ERRFMT
C* Extract output and return
C* my particular situation has 12/2 input, so I need 18 output
C                     MOVELEOUTPT    CHAR18 18
C                     SETON                     LR

Buck Calabro
Commsoft; Albany, NY
Visit the Midrange archives and FAQ at http://www.midrange.com
"As a rule, men worry more about what they can't see than
 about what they can." -- Julius Caesar




As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.