ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Which sqlClientMap's method to use to execute the "MERGE INTO" statement?
Date Thu, 09 Mar 2006 04:43:12 GMT
I would use "update" - the DB2 example for merge with JDBC uses a JDBC
update statement - and that would match iBATIS' update, insert, or delete -
but update makes the most sense to me.

Using "queryForObject" will tell iBATIS that a commit is not needed - which
might be the cause of the error you are seeing.

Jeff Butler

On 3/8/06, Vu, Thai <Thai.Vu@parsons.com> wrote:
> I hope the subject says it all.
> I have:
> <statement id="applyDeltaFunding"
>             parameterClass=" beans.NonMilconFundingProfileBean">
>    MERGE INTO NonMilconFunding a
>      USING (SELECT $projectref$ AS projectref, $year$ AS year,
> $saved_deltas$ AS saved_delta
>               FROM dual) b
>      ON (a.projectref = b.projectref AND a.year = b.year)
>      WHEN MATCHED THEN UPDATE SET a.saved_delta = null
>                                 , a.funded = a.funded + b.saved_delta
>      WHEN NOT MATCHED THEN INSERT (a.projectref, a.year, a.funded)
>                            VALUES (b.projectref, b.year, b.saved_delta)
> </statement>
> How can I execute this statement in Java? (I mean, should I use
> sqlClient.queryForObject("applyDeltaFunding", instance)?).
> I tried with queryForObject. No errors occurred but nothing is written
> to the database. I went to the log file to get the sql statement and run
> it manually and it's fine.
> Thanks in advance for any help.

View raw message