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, ^ _ ^