Home > Database > Mysql Tutorial > Mybatis批量增加,删除,更新Oracle

Mybatis批量增加,删除,更新Oracle

WBOY
Release: 2016-06-07 15:19:44
Original
1750 people have browsed it

最近需要用到Mybatis批量新增oracle数据库,刚开始在网上找到的方法是都是更新mySQL的,试了一下发现不适合Oracle,后来发现正确的oracle批量新增的sql是: insert id=insertAttractionsBatch parameterType=java.util.List insert into ATTRACTIONS ( ID, N

最近需要用到Mybatis批量新增oracle数据库,刚开始在网上找到的方法是都是更新mySQL的,试了一下发现不适合Oracle,后来发现正确的oracle批量新增的sql是:


insert into ATTRACTIONS (

ID, NAME, LONGITUDE, LATITUDE,  UPDATE_TIME

)

   
      (select  
#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.longitude,jdbcType=DECIMAL}, #{item.updateTime,jdbcType=TIMESTAMP}
       from dual)
   


新增:


insert into ATTRACTIONS (

ID, NAME, LONGITUDE, LATITUDE,  UPDATE_TIME

)  
   
#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.longitude,jdbcType=DECIMAL}, #{item.updateTime,jdbcType=TIMESTAMP}
   

oracle更新不能按普通的方式,需要这样:


    begin  
        
            update ATTRACTIONS
            
            
                id = #{item.id},
            

           
                HEAD = #{item.head},
            

           
            where id = #{item.id}
            
        ;end;
    

删除就与MySql一样了如下:


  delete from ATTRACTIONS
 
      
 id=#{item.id}
   

 

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template