Focal Point
[SOLVED]Problem inserting timestamp from webfocus to DB2

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/8517010476

December 22, 2014, 01:04 AM
Ramya
[SOLVED]Problem inserting timestamp from webfocus to DB2
Hi,

I am trying to insert some values from Webfocus into DB2 table.

I am using the following code. &NOW is giving out he timestamp in correct format that is expaected.


-SET &NOW = HCNVRT(HGETC(8,'HYYMDm'),'(HYYMDS)',30,'A30');

ENGINE DB2 SET DEFAULT_CONNECTION DATABASE
SQL DB2
INSERT INTO SCHEMA.TABLENAME
(APPLICATION_NAME,
REPORT_RUN_TIME,
FLAG)
VALUES(
'XXX',
'&NOW',
'Y');
END
-RUN

When I try to run the above query, I am getting the following error.

(FOC1400) SQLCODE IS -180 (HEX: FFFFFF4C)
: [22007] [IBM][CLI Driver][DB2/AIX64] SQL0180N The syntax of the string
: representation of a datetime value is incorrect. SQLSTATE=22007
(FOC1414) EXECUTE IMMEDIATE ERROR.


Regards,
Ramya

This message has been edited. Last edited by: Ramya,


WebFocus 7702
HTML
December 22, 2014, 02:17 AM
Ram Prasad E
quote:
timestamp in correct

Looks like DB column is in Date time format. Can you share the DB format for column - REPORT_RUN_TIME.

But NOW variable is in Alpha format. Use .TYPE to verify format of amper variables.
-SET &NOW = HCNVRT(HGETC(8,'HYYMDm'),'(HYYMDS)',30,'A30');

-TYPE FORMAT OF VARIABLE NOW: &NOW &NOW.TYPE


Thanks,
Ram


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
December 22, 2014, 02:47 AM
Ramya
quote:
share the DB format for column


Hi Ram,

You are right. The DB format of the column 'REPORT_RUN_TIME is 'TIMESTAMP' and the date we are trying to insert is 'Alpha'.

I want your help in converting the type from 'Alpha' to 'DateTime'.

Regards.
Ramya


WebFocus 7702
HTML
December 22, 2014, 03:45 AM
Ram Prasad E
You need to change the alpha date format to timestamp format while inserting the values. Below code should work. Also this is related to DB2 nothing to do with WebFOCUS.
INSERT INTO SCHEMA.TABLENAME (APPLICATION_NAME,REPORT_RUN_TIME,FLAG)
VALUES ('XXX', TIMESTAMP_FORMAT('&NOW.EVAL','YYYY/MM/DD HH24:MI:SS') ,'Y')


Thanks,
Ram


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
December 22, 2014, 05:07 AM
Ramya
quote:
TIMESTAMP_FORMAT('&NOW.EVAL','YYYY/MM/DD HH24:MI:SS')

Thanks Ram,

That worked.

Regards,
Ramya


WebFocus 7702
HTML
December 22, 2014, 06:54 AM
Ram Prasad E
Good to see it solved your problem.
Mark subject line of your first post to SOLVED.


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/