SELECT
MEMBER
,SUBSTR(INSTANCENAME,1,8) AS INSTANCENAME
,SUBSTR(DBNAME,1,8) AS DBNAME
,TIMESTAMP
,LEVEL
,SUBSTR(IMPACT,1,10) AS IMPACT
,EDU_ID
,substr(EDUNAME,1,25) as EDUNAME
,PID
,substr(PROCESS_NAME,1,25) as PROCESS_NAME
,TID
,substr(APPLICATION_ID,1,35) as APPLICATION_ID
,APPLHANDLE
,substr(AUTH_ID,1,8) as AUTH_ID
,OSERR
,RETCODE
,MSGNUM
,substr(rtrim(OBJNAME_QUALIFIER)||'.'||OBJNAME,1,65) as object
,substr(EVENTTYPE,1,15) as EVENTTYPE
,CASE
WHEN LENGTH(MSG) > 407 THEN
SUBSTR(rtrim(REPLACE(MSG,X'0A',' ')),1,150) || ' (...) ' || SUBSTR(RIGHT(REPLACE(MSG,X'0A',' '),150),1,250)
ELSE
SUBSTR(rtrim(REPLACE(MSG,X'0A',' ')),1,407)
END AS MSG
-- PD_GET_DIAG_HIST--(--facility--,--rectype--,--impact--,--start_time--,--end_time--,--member--)
FROM TABLE(PD_GET_DIAG_HIST(NULL, NULL, NULL, TIMESTAMP('2007-09-23-15.53.37'), TIMESTAMP('2007-09-24-15.53.37'), -2))