In. net, the data access component (Oracle. dataaccess. dll) provided by Oracle products is used to improve the execution efficiency of batch update operations.

Source: Internet
Author: User
Tags oracleconnection
// Dynamic link library path
$ Oracle installation path $/bin/oracle. dataaccess. dll
// Namespace reference
Using Oracle. dataaccess. client;
// Rough description of the Encoding Process
Int rowscount = 10; // it is assumed that 10 records need to be deleted.
Oracle. dataaccess. Client. oracleconnection connection = new Oracle. dataaccess. Client. oracleconnection ("connection string here ");
Connection. open ();
Oracle. dataaccess. Client. oracletransaction trans = connection. begintransaction ();
Oracle. dataaccess. Client. oraclecommand cmd = new Oracle. dataaccess. Client. oraclecommand ("delete from sample where id =: v_id ");
Oracle. dataaccess. Client. oracleparameter [] parameters = new Oracle. dataaccess. Client. oracleparameter [1];
// Initialization and type declaration operations on parameters [0] are omitted here
Cmd. Connection = connection;
Cmd. arraybindcount = rowscount;
For (INT I = 0; I <parameters. length; I ++)
{
Parms [I]. value = new object [] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // you can assign values to all parameters in batches.
}
Foreach (Oracle. dataaccess. Client. oracleparameter Param in parameters)
{
Cmd. Parameters. Add (PARAM );
}
Cmd. executenonquery ();
Trans. Commit ();
Connection. Close ();
// Performance optimization description
This method uses the batch value assignment mode of the same parameter to make full use of the efficient parameter cache mechanism provided by the database product, thus reducing the statement parsing time (using system. data. in oracleclient mode, the query statement with the same parameters needs to be re-parsed during each execution.) In this mode, the execution efficiency and performance are improved when a large volume of data is updated.
 
Related Article

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.