Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MyBatis executing multiple sql statements in one go, is that possible?

i was wondering if it is possible to execute multiple sql statements in 1 go. For example the scenario that i want to delete rows from multiple tables, is there a way i can do things like..

<delete id="delete" parameterType="String">
    DELETE FROM DUMMYTABLE_A where X=${value}
    DELETE FROM DUMMYTABLE_B where X=${value}
</delete>
like image 747
Marco Avatar asked Aug 24 '11 10:08

Marco


1 Answers

I'm using myBatis with Oracle. I guess there is something similar in other DB. Actually you always can create procedures in DB, which usually is better for the future, when you have to support the project.

<delete id="deleteUnfinishedData" parameterType="map">
    {call
        declare
        begin
            delete from TABLE1 where id = #{valueFromMap1};
            delete from TABLE2 where id = #{valueFromMap2};
        end
    }
</delete>
like image 195
StrekoZ Avatar answered Sep 29 '22 02:09

StrekoZ