You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Fred Janon <fj...@yahoo.com> on 2006/07/08 09:12:02 UTC
How to use a function on a parameter in an "update" mapped statement?
Hi,
I want to convert a string containing a date in the format dd/month/year
into a mySQL date format (YYYY/mm/dd) in an update statement. I tried:
<mapped-statement name="saveJob">
update jobs
set clientid=#clientId#, summary=#summary#, jobduedate=str_to_date(#dueDate#, '%d/%m/%Y')
where jobid=#id#
</mapped-statement>
but it doesn't work or even generate an error, it jut stores 0000/00/00
in the my SQL DB. I enabled DEBUG on SQL statements and apparently the
generated statement by iBatis is:
PreparedStatement: update jobs set clientid=?, summary=?, jobduedate=? where jobid=?
Parameters: [2, Yellow banner 7, 10/10/2000, 3]
No sign of my function call at all.
Is there a way to get my function call working?
Thanks
Fred
Re: How to use a function on a parameter in an "update" mapped statement?
Posted by Larry Meadors <lm...@apache.org>.
Nope, I think there is something else going on here...iBATIS is not
changing your SQL...so if it says "jobduedate=?" then that is what is
in the SQL map.
How are you building the application?
Larry
On 7/11/06, Fred Janon <fj...@yahoo.com> wrote:
> Hi Ted,
>
> Thanks for the suggestion, I looked at the link you mentioned, but I
> don't think that's the issue. It looks like iBatis doesn't even generatr
> the correct statement if the log is correct:
>
> PreparedStatement: update jobs set clientid=?, summary=?,
> jobduedate=? where jobid=?
>
> In this statement, "jobduedate=?" should actually genarated as
> "jobduedate=str_to_date(?, '%d/%m/%Y')" I think.
>
> I hope someone gives me a pointer here, I have the suspicion that iBatis
> just replaces the right hand side of the '=' by '?' and ignores the
> actual RHS expression.
>
> Fred
>
> Ted Schrader wrote:
> > Hi Fred,
> >
> > Does mySQL allow place holders inside of functions for JDBC? For
> > example:
> >
> > update jobs
> > set clientid=?, summary=?, jobduedate=str_to_date(?)
> > where jobid=?
> >
> > I ran into a similar problem with DB2 on the AS400/iSeries/i5. Check
> > out the last entry on
> > http://opensource.atlassian.com/confluence/oss/display/IBATIS/Environment+Specific+Information
> >
> >
> > Ted
> >
> >
> > On 08/07/06, Fred Janon <fj...@yahoo.com> wrote:
> >> Hi,
> >>
> >> I want to convert a string containing a date in the format dd/month/year
> >> into a mySQL date format (YYYY/mm/dd) in an update statement. I tried:
> >>
> >> <mapped-statement name="saveJob">
> >> update jobs
> >> set clientid=#clientId#, summary=#summary#,
> >> jobduedate=str_to_date(#dueDate#, '%d/%m/%Y')
> >> where jobid=#id#
> >> </mapped-statement>
> >>
> >> but it doesn't work or even generate an error, it jut stores 0000/00/00
> >> in the my SQL DB. I enabled DEBUG on SQL statements and apparently the
> >> generated statement by iBatis is:
> >>
> >> PreparedStatement: update jobs set clientid=?, summary=?,
> >> jobduedate=? where jobid=?
> >> Parameters: [2, Yellow banner 7, 10/10/2000, 3]
> >>
> >> No sign of my function call at all.
> >>
> >> Is there a way to get my function call working?
> >>
> >> Thanks
> >>
> >> Fred
> >>
> >>
> >>
> >>
> >>
> >>
> >
>
>
>
Re: How to use a function on a parameter in an "update" mapped statement?
Posted by Fred Janon <fj...@yahoo.com>.
Hi Ted,
Thanks for the suggestion, I looked at the link you mentioned, but I
don't think that's the issue. It looks like iBatis doesn't even generatr
the correct statement if the log is correct:
PreparedStatement: update jobs set clientid=?, summary=?,
jobduedate=? where jobid=?
In this statement, "jobduedate=?" should actually genarated as
"jobduedate=str_to_date(?, '%d/%m/%Y')" I think.
I hope someone gives me a pointer here, I have the suspicion that iBatis
just replaces the right hand side of the '=' by '?' and ignores the
actual RHS expression.
Fred
Ted Schrader wrote:
> Hi Fred,
>
> Does mySQL allow place holders inside of functions for JDBC? For
> example:
>
> update jobs
> set clientid=?, summary=?, jobduedate=str_to_date(?)
> where jobid=?
>
> I ran into a similar problem with DB2 on the AS400/iSeries/i5. Check
> out the last entry on
> http://opensource.atlassian.com/confluence/oss/display/IBATIS/Environment+Specific+Information
>
>
> Ted
>
>
> On 08/07/06, Fred Janon <fj...@yahoo.com> wrote:
>> Hi,
>>
>> I want to convert a string containing a date in the format dd/month/year
>> into a mySQL date format (YYYY/mm/dd) in an update statement. I tried:
>>
>> <mapped-statement name="saveJob">
>> update jobs
>> set clientid=#clientId#, summary=#summary#,
>> jobduedate=str_to_date(#dueDate#, '%d/%m/%Y')
>> where jobid=#id#
>> </mapped-statement>
>>
>> but it doesn't work or even generate an error, it jut stores 0000/00/00
>> in the my SQL DB. I enabled DEBUG on SQL statements and apparently the
>> generated statement by iBatis is:
>>
>> PreparedStatement: update jobs set clientid=?, summary=?,
>> jobduedate=? where jobid=?
>> Parameters: [2, Yellow banner 7, 10/10/2000, 3]
>>
>> No sign of my function call at all.
>>
>> Is there a way to get my function call working?
>>
>> Thanks
>>
>> Fred
>>
>>
>>
>>
>>
>>
>
Re: How to use a function on a parameter in an "update" mapped statement?
Posted by Ted Schrader <ts...@gmail.com>.
Hi Fred,
Does mySQL allow place holders inside of functions for JDBC? For example:
update jobs
set clientid=?, summary=?, jobduedate=str_to_date(?)
where jobid=?
I ran into a similar problem with DB2 on the AS400/iSeries/i5. Check
out the last entry on
http://opensource.atlassian.com/confluence/oss/display/IBATIS/Environment+Specific+Information
Ted
On 08/07/06, Fred Janon <fj...@yahoo.com> wrote:
> Hi,
>
> I want to convert a string containing a date in the format dd/month/year
> into a mySQL date format (YYYY/mm/dd) in an update statement. I tried:
>
> <mapped-statement name="saveJob">
> update jobs
> set clientid=#clientId#, summary=#summary#, jobduedate=str_to_date(#dueDate#, '%d/%m/%Y')
> where jobid=#id#
> </mapped-statement>
>
> but it doesn't work or even generate an error, it jut stores 0000/00/00
> in the my SQL DB. I enabled DEBUG on SQL statements and apparently the
> generated statement by iBatis is:
>
> PreparedStatement: update jobs set clientid=?, summary=?, jobduedate=? where jobid=?
> Parameters: [2, Yellow banner 7, 10/10/2000, 3]
>
> No sign of my function call at all.
>
> Is there a way to get my function call working?
>
> Thanks
>
> Fred
>
>
>
>
>
>