Author |
Message
|
saurabh25281 |
Posted: Thu Dec 16, 2010 1:48 am Post subject: Unable to cast to ESQL TIMESTAMP variable |
|
|
Centurion
Joined: 05 Nov 2006 Posts: 108 Location: Bangalore
|
I am trying to get athe current timestamp from a DB2 database and store it to a ESQL TIMESTAMP variable, but the value is not populated.
The code does not throw any errors and i am able to see the value in the unique1 environment variable during debugging.
Is there any problem with the code?
DECLARE TEST_TS1 TIMESTAMP;
SET Environment.Variables.unique1 = PASSTHRU('SELECT current timestamp FROM SYSIBM.SYSDUMMY1');
SET TEST_TS1 = CAST (Environment.Variables.unique2 AS TIMESTAMP FORMAT ('yyyy-MM-dd HH:mm:ss.SSS')); |
|
Back to top |
|
 |
fatherjack |
Posted: Thu Dec 16, 2010 2:02 am Post subject: Re: Unable to cast to ESQL TIMESTAMP variable |
|
|
 Knight
Joined: 14 Apr 2010 Posts: 522 Location: Craggy Island
|
saurabh25281 wrote: |
Environment.Variables.unique2 |
Is this a typo or is it really your code ? _________________ Never let the facts get in the way of a good theory. |
|
Back to top |
|
 |
saurabh25281 |
Posted: Thu Dec 16, 2010 2:05 am Post subject: |
|
|
Centurion
Joined: 05 Nov 2006 Posts: 108 Location: Bangalore
|
Sorry typo...it should be unique1
Environment.Variables.unique1 |
|
Back to top |
|
 |
good_bee |
Posted: Thu Dec 16, 2010 2:39 am Post subject: |
|
|
Newbie
Joined: 15 Nov 2010 Posts: 5
|
Saurabh
I think you can only use FORMAT from BIT, BLOB or CHAR to TIMESTAMP and not from timestamp to timestamp.
Code: |
You can specify a FORMAT parameter when casting:
From any of the string data types (BIT, BLOB, or CHARACTER) to:
DECIMAL
FLOAT
INTEGER
DATE
GMTTIMESTAMP
TIMESTAMP
GMTTIME
TIME
To any of the string data types (BIT, BLOB, or CHARACTER) from any of the numerical and date/time data types in the previous list.
|
|
|
Back to top |
|
 |
saurabh25281 |
Posted: Thu Dec 16, 2010 2:51 am Post subject: |
|
|
Centurion
Joined: 05 Nov 2006 Posts: 108 Location: Bangalore
|
I tried using CHARACTER instead of TIMESTAMP but for no use.
is it something related to ROWS being returned by the DB2 database which I am not handling. |
|
Back to top |
|
 |
good_bee |
Posted: Thu Dec 16, 2010 3:08 am Post subject: |
|
|
Newbie
Joined: 15 Nov 2010 Posts: 5
|
Saurabh
you can first CAST the timestamp that you had retrieved from DB2 into a string and then cast that String into timestamp of your required format. |
|
Back to top |
|
 |
|