ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » DATE issue

Post new topic  Reply to topic
 DATE issue « View previous topic :: View next topic » 
Author Message
firoj.badsa
PostPosted: Sun Jul 12, 2009 11:29 am    Post subject: DATE issue Reply with quote

Centurion

Joined: 16 Feb 2007
Posts: 104

I have a input XML file which have a date format of YYYYMMDD. I want to insert date in database table in the same format.

<Message>
...........
...........
<date></date>
..........
..........
</Message>

INSERT Command fails while I am trying to use Message.date as value for the field. It seems i have to alter the date field value. Can anyone please help.

Regards,
Firoj
Back to top
View user's profile Send private message
Vitor
PostPosted: Sun Jul 12, 2009 11:51 am    Post subject: Re: DATE issue Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

firoj.badsa wrote:
I want to insert date in database table in the same format.
...........
It seems i have to alter the date field value. Can anyone please help.


If you have to insert date into the database table in the same format then you need to alter the database column so it allows the insert.

Or you need to insert the date into the existing format you'll need to write some ESQL (or similar) to reformat the date.

Of course, if we knew why the INSERT failed because you'd posted the error there might be more suggestions.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Sun Jul 12, 2009 12:19 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Or perhaps firoj.badsa has used XMLNS or XMLNSC without a schema, such that the XML data is not being turned into a date value at all, but remains the string of characters that makes up the contents of all XML fields.
Back to top
View user's profile Send private message
Vitor
PostPosted: Sun Jul 12, 2009 12:25 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

mqjeff wrote:
Or perhaps firoj.badsa has used XMLNS or XMLNSC without a schema, such that the XML data is not being turned into a date value at all, but remains the string of characters that makes up the contents of all XML fields.


Indeed, though I would have hoped if it was as simple as a character string being presented to a database date field there would have been an implicit conversion. I suspect this issue is that the database expects "YYYY/MM/DD" or "DDMMYYYY" to convert.

Though of course you could get round all this using a schema as you suggest and presenting a date.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
firoj.badsa
PostPosted: Sun Jul 12, 2009 10:22 pm    Post subject: Reply with quote

Centurion

Joined: 16 Feb 2007
Posts: 104

Hi,

I am using MRM parser for the XML message. I am getting the below error message ...

[IBM][CLI Driver][DB2/NT] SQL0180N The syntax of the string
representation of a datetime value is incorrect. SQLSTATE=22007

Thanks!
Back to top
View user's profile Send private message
smdavies99
PostPosted: Sun Jul 12, 2009 11:18 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

firoj.badsa wrote:
Hi,
[IBM][CLI Driver][DB2/NT] SQL0180N The syntax of the string
representation of a datetime value is incorrect. SQLSTATE=22007


How is the Database colum defined?
Can you give us the ESQL data type you are using for the Date and also the output from a user trace showing the actual value you art trying to insert.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
firoj.badsa
PostPosted: Mon Jul 13, 2009 12:15 am    Post subject: Reply with quote

Centurion

Joined: 16 Feb 2007
Posts: 104

database column was defined as datatype DATE;

SET CH_TargetDate = SUBSTRING ( TEMP FROM 5 FOR 2 ) ||'/'||SUBSTRING ( TEMP FROM 7 FOR 2 )||'/'||SUBSTRING ( TEMP FROM 1 FOR 4 );

In trace window i can see CH_TargetDate having value 02/02/2009.

Still the insert command fails.

Thanks
Back to top
View user's profile Send private message
vmcgloin
PostPosted: Mon Jul 13, 2009 12:46 am    Post subject: Reply with quote

Knight

Joined: 04 Apr 2002
Posts: 560
Location: Scotland

Hi,

You should check with your DBA what format is expected. Or check the db2cli.ini DateTimeStringFormat keyword. If it is not USA then it won't work with that format.

Alternatively, experiment from the command line - try inserting with yyyy-mm-dd as I guess that might be the most likely setting.

It does not seem like a message broker problem and the error message is quite helpful...however there might be a better way to cast your date to another format without concatenating substrings.

Cheers,
Vicky
Back to top
View user's profile Send private message
smdavies99
PostPosted: Mon Jul 13, 2009 1:03 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

From a DB2 command line on Windows, I can use two formats to insert a date.

create table db2admin.mytest (ZZDATE DATE NOT NULL, ZZCHAR CHAR(30) NULL)
insert into db2admin.mytest (zzdate) values ('2009-03-03','Hello World 1')
insert into db2admin.mytest (zzdate) values ('03-03-2009','Hello World 2')
select * from db2admin.mytest

ZZDATE
-------------------------------------------------
03/03/2009 Hello World 1
03/03/2009 Hello World 2
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
firoj.badsa
PostPosted: Mon Jul 13, 2009 1:19 am    Post subject: Reply with quote

Centurion

Joined: 16 Feb 2007
Posts: 104

Yup.. From DB2 command line its working fine.. but i donno why this fails from compute node.

[IBM][CLI Driver][DB2/NT] SQL0180N The syntax of the string
representation of a datetime value is incorrect. SQLSTATE=22007
Back to top
View user's profile Send private message
firoj.badsa
PostPosted: Mon Jul 13, 2009 1:39 am    Post subject: Reply with quote

Centurion

Joined: 16 Feb 2007
Posts: 104

Working fine now!

The column was created with wrong datatype! I was expecting a DATE datatype but DBA created with TIMESTAMP datatype.

Thanks all for your help.

Regards,
Firoj
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » DATE issue
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.