View previous topic :: View next topic
|
Author |
Message |
muralikrishnan_new
New User
Joined: 02 Jun 2013 Posts: 15 Location: India
|
|
|
|
Hi,
I am Converting a EBCDIC Timestamp value to Unicode Timestamp value to use it in my Db2 table.
Code: |
01 WS-EBCD-TS PIC X(26) VALUE '2016-04-18-01.12.11.005634'.
01 WS-UNCD-TS PIC N(26).
.......
......
......
Move Function national-of(WS-EBCD-TS) TO WS-UNCD-TS
EXEC SQL
SELECT LENGTH(COL1)
FROM TABLE1
WHERE LATE_TS = :WS-UNCD-TS
END-EXEC
|
I am getting sqlcode -180.
Code: |
SQLCODE -180
SQLCABC +136
SQLSTATE 22007
SQLERRD +186
|
I have even tried the below SQL
Code: |
EXEC SQL
SELECT LENGTH(COL1)
FROM TABLE1
WHERE LATE_TS = CAST(:WS-UNCD-TS AS TIMESTAMP(6) CCSID UNICODE)
END-EXEC
|
But still i am getting the same SQLCODE. Is there any way to convert Timestamp from EBCDIC to unicode timestamp .
Please help me to correct if i have made any mistakes. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
|
|
Shouldn't it be?
Code: |
CAST(:WS-EBCD-TS TIMESTAMP(6) CCSID UNICODE |
Ensure there is no truncation
|
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
db2 should take care of it by itself. it will recognize that the host-variable is EBCDIC and that the table is unicode (if it is?) and take care of the the translation for you. |
|
Back to top |
|
|
|