Java oracle data multiple insert

Using Oracle data insert in Java code, batch insert operation

 

   // Each select statement gets a piece of data, and then uses the set operator union to combine multiple pieces of data into a result set to achieve the function of inserting multiple pieces of data at one time

 

StringBuffer s = new StringBuffer("insert into table(name,id)");

     //Use the for loop to insert ten pieces of data in batches

         for(int i = 0; i < 10; i++){

             s.append( select 'name','id' from dual);

     //Do not write "union" for the tenth time of the judgment loop

        if(i < 10 - 1){

                s.append(" union");

                }

        }

   //If an exception of java.lang.StringBuffer is reported

       String str = s.toString();

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326763126&siteId=291194637