C ++ completes batch insertion of Oracle stored procedures (2). oracle stored procedures

Source: Internet
Author: User

C ++ completes batch insertion of Oracle stored procedures (2). oracle stored procedures

The previous article briefly introduced how oracle parameters are stored in an Object-type database and how JAVA uses JDBC to call stored procedures of this type. However, I need a solution in C ++. I didn't find any method that can call this type of stored procedure using the Poco library, but the function still needs to be implemented, later I found that Oracle supports XML parsing, so I had the following solution: the stored procedure parameters are of the CLOB type, and C ++ calls the stored procedure by passing in the XML format string, after parsing xml in the stored procedure, insert the data into the database.

(With the above scheme, I guess the JDBC processing method may also be to input a string in XML format to the Oracle database. Oracle can convert XML to Object objects internally, finally, pass this Object parameter to the stored procedure)

The main code for this solution is as follows:

1) Oracle Stored Procedure

create or replace procedure POCO_TEST_XML_CLOB_PRO(v_xml in CLOB) isbegin  INSERT INTO POCO_TEST(ID,name,code)  SELECT * FROM XMLTABLE('$B/Parment/PocoTest' PASSING    XMLTYPE(v_xml) AS B    COLUMNS ID VARCHAR2(50) PATH    '/PocoTest/ID',    NAME VARCHAR2(50) PATH    '/PocoTest/Name',    CODE VARCHAR2(50) PATH    '/PocoTest/Code');end POCO_TEST_XML_CLOB_PRO;

2) call C ++ code

std::string str;ODBCObject::getCollectionXmlStr(str,arr);Poco::Data::CLOB clob(str.c_str(),str.size());session << "{call POCO_TEST_XML_CLOB_PRO(?)}", Poco::Data::Keywords::in(clob),  Poco::Data::Keywords::now;


Here is the complete project code.


Batch insert of oracle stored procedures

Use cursor for Stored Procedure
It is best not to create an index for the table to be inserted.

 
A batch data insertion stored procedure in oracle

You can use Orcel to import data. You can search for it online,
There are a lot of software downloads in this area, so it will be very fast,
Haha, hope to help, ^ _ ^
 

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.