CSS

Showing posts with label DB2. Show all posts
Showing posts with label DB2. Show all posts

Thursday, May 17, 2012

DB2 Converting YYYYMMDD to timestamp

So my company has a iSeries server that includes a legacy application that stored dates as YYYYMMDD numeric(8,0). Time are stored as HHMM numeric(4,0). I have finally been able to create a function that take these 2 types of columns and return a timestamp.

 On of the cool things about the iSeries is that a data file that is written to my a legacy RPG program can be munipultated using SQL. From a client like JDBC or some DB2 client those file look just like a table. This is why the legacy applications did not store the date in a TIMESTAMP column. below is the function.

CREATE FUNCTION COMMON.TIMESTAMP_FROM_YFU (
YFUDATE NUMERIC(8, 0) ,
YFUTIME NUMERIC(4, 0) )
RETURNS TIMESTAMP  
LANGUAGE SQL
SPECIFIC COMMON.TIMESTAMP_FROM_YFU
DETERMINISTIC
CONTAINS SQL
RETURNS NULL ON NULL INPUT
NO EXTERNAL ACTION
SET OPTION  ALWBLK = *ALLREAD ,
ALWCPYDTA = *OPTIMIZE ,
COMMIT = *NONE ,
DECRESULT = (31, 31, 00) ,
DFTRDBCOL = *NONE ,
DYNDFTCOL = *NO ,
DYNUSRPRF = *USER ,
SRTSEQ = *HEX  
RETURN TIMESTAMP_FORMAT ( VARCHAR ( YFUDATE ) || DIGITS ( YFUTIME ) , 'YYYYMMDDHH24MI' )  ;
 
COMMENT ON SPECIFIC FUNCTION COMMON.TIMESTAMP_FROM_YFU
IS 'Timestamp from YFU Date and time' ;

Wednesday, August 3, 2011

DB2Plugin Added to Wonder

The DB2 database plugin for WebObjects that I wrote has been added to the Wonder Framework.  The Plugin supports both mainstream DB2 and DB2 for iSeries.  The biggest pain for using the plugin is getting the DB2 jars.  Check the README files for help on that.