I think you need to turn on logging and see what's actually being sent to the DB.  Something is messed up, but it's hard to tell what it is.
 
Jeff Butler

 
On 1/26/06, Bondre, Prathit <[EMAIL PROTECTED]> wrote:

Hi Jeff,

 

I have tried that as well.

I am able to run it if I hard code the value. So my string format seems to be ok.

For e.g.

If I change my query to

Insert into table
Select
  Address,
  City,
  Zip,
  'Fred' as name,
 '2006-01-01' as date
>From Table
Where Id = #id#

 

it works.

 

But as soon as I pass it as a string in the hashmap it gives me the data type mismatch error.

 

 


From: Jeff Butler [mailto: [EMAIL PROTECTED]]
Sent: Thursday, January 26, 2006 11:44 AM
To: user-java@ibatis.apache.org
Subject: Re: iBatis Subquery and Date error

 

My guess is that you've not really got the String format for a Date right for your database.  It is notoriously difficult to specify a String for a date.  You might try to prototype the insert statement in some interactive database client (like squirrel) to get it working before you try the iBATIS stuff.

 

You probably also need to do a "cast" - use the database function to convert a String to a date.  If you were using DB2, it would look like this:

 

Insert into table
Select
  Address,
  City,
  Zip,
  'Fred' as name,
  date('yyyynnn') as date
From Table
Where Id = #id#

Where 'yyyynnn' is a Julian date.

Jeff Butler

 

On 1/26/06, Bondre, Prathit < [EMAIL PROTECTED] > wrote:

Hi Jeff,

 

Thanks for your response.

I tried that as well but when I pass in a String with the database specific format it give me a cast mismatch error.

"Value not compatible with the datatype of its assignment target".

 

Any ideas?

 


Reply via email to