Add, delete, and update Oracle in batches using Mybatis

Source: Internet
Author: User
Recently, I used Mybatis to add oracle databases in batches. The methods I found online at the beginning were to update mySQL. I tried it and found it was not suitable for Oracle, later, we found that the correct SQL statement added in batch in oracle is: insertidinsertAttractionsBatchparameterTypejava. util. listinsertintoATTRACTIONS (ID, N

Recently, I used Mybatis to add oracle databases in batches. The methods I found online at the beginning were to update mySQL. I tried it and found it was not suitable for Oracle, later, we found that the correct SQL statement added in batch in oracle is: insert id = insertAttractionsBatch parameterType = java. util. list insert into ATTRACTIONS (ID, N

Recently, I used Mybatis to add oracle databases in batches. The methods I found online at the beginning were to update mySQL. I tried it and found it was not suitable for Oracle, later, we found that the correct SQL statements added in batch in oracle are:


Insert into ATTRACTIONS (

ID, NAME, longpolling, LATITUDE, UPDATE_TIME

)


(Select
# {Item. id, jdbcType = VARCHAR}, # {item. name, jdbcType = VARCHAR}, # {item. longpolling, jdbcType = DECIMAL}, # {item. updateTime, jdbcType = TIMESTAMP}
From dual)


New:


Insert into ATTRACTIONS (

ID, NAME, longpolling, LATITUDE, UPDATE_TIME

)

# {Item. id, jdbcType = VARCHAR}, # {item. name, jdbcType = VARCHAR}, # {item. longpolling, jdbcType = DECIMAL}, # {item. updateTime, jdbcType = TIMESTAMP}

Oracle update cannot be implemented in the normal way. You need:


Begin

Update ATTRACTIONS


Id = # {item. id },


HEAD = # {item. head },


Where id = # {item. id}

; End;


The deletion is the same as MySql:


Delete from ATTRACTIONS


Id = # {item. id}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.