-- Create the DATE UDF (User Defined Functions) using
-- the routines in the DATE_SQL Service program.

set schema lennons1;  -- CHANGE TO YOUR LIBRARY
set path   lennons1;  -- CHANGE TO YOUR LIBRARY

DROP FUNCTION DATE_MDY
;
CREATE OR REPLACE FUNCTION DATE_MDY
        (INDATE  DECIMAL(8,0) )
        RETURNS DATE
        PARAMETER STYLE SQL
        LANGUAGE RPGLE
        NO SQL
        DETERMINISTIC
        EXTERNAL NAME 'DATE_SQL(DATE_MDY)'
        RETURNS NULL ON NULL INPUT
        NO EXTERNAL ACTION
;
DROP FUNCTION DATE_YMD
;
CREATE OR REPLACE FUNCTION DATE_YMD
        (INDATE  DECIMAL(8,0) )
        RETURNS DATE
        PARAMETER STYLE SQL
        LANGUAGE RPGLE
        NO SQL
        DETERMINISTIC
        EXTERNAL NAME 'DATE_SQL(DATE_YMD)'
        RETURNS NULL ON NULL INPUT
        NO EXTERNAL ACTION
;
DROP FUNCTION DATE_CYMD
;
CREATE OR REPLACE FUNCTION DATE_CYMD
        (INDATE  DECIMAL(8,0) )
        RETURNS DATE
        PARAMETER STYLE SQL
        LANGUAGE RPGLE
        NO SQL
        DETERMINISTIC
        EXTERNAL NAME 'DATE_SQL(DATE_CYMD)'
        RETURNS NULL ON NULL INPUT
        NO EXTERNAL ACTION
;
