Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8404891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:43:00+00:00 2026-06-09T22:43:00+00:00

I have the following PL/SQL block that creates a procedure to insert a new

  • 0

I have the following PL/SQL block that creates a procedure to insert a new cat:

CREATE OR REPLACE PROCEDURE INSERT_NEW_CAT(AGE NUMBER, WEIGHT NUMBER, NAME VARCHAR2)  
AS  
BEGIN    
     INSERT INTO CATS(cat_id,age,weight,name)  
     VALUES(cat_id_sequence.nextval,age,weight,name);  
END  INSERT_NEW_CAT;

And the following Java block to batch insert these cats:

CallableStatement statement = conn.prepareCall("{CALL insert_new_cat(?,?,?)}");  
for(int i = 0; i < 50000;i++)  
{  
    statement.setInt(1, i);  
    statement.setInt(2,i);  
    statement.setString(3,"Test");  
    statement.addBatch();  
    if(i % 16382== 0)  //max value my batch can support on my hardware
    {  
         statement.executeBatch();  
    }  
}  

statement.executeBatch();  

So the issue with this is I can only persist 700 records a second, which is quite slow. I believe the issue is that I invoke the above PL/SQL function once per row (or once per batch entry). How can I re-write the above function to take an array of these statements and do a bulk insert to reduce the number of calls to the function to N modulo 16382 + 1? The database is Oracle 10g.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:43:02+00:00Added an answer on June 9, 2026 at 10:43 pm

    I was able to solve the problem using the following steps:

    Creation of Oracle objects to reference my Cat attributes:

    Create Type age is table of number  
    Create Type weight is table of number  
    Create Type name is table of varchar(50) 
    

    Then in my Java code I did the following:

    ArrayDescriptor ageCollection = ArrayDescriptor.createDescriptor("AGE", conn);   
    ArrayDescriptor weightCollection = ArrayDescriptor.createDescriptor("WEIGHT", conn); 
    ArrayDescriptor nameCollection = ArrayDescriptor.createDescriptor("NAME", conn);   
    int[] ageArray = new int[50000];  
    int[] weightArray = new int[50000];  
    String[] nameArray = new String[50000];  
    for(int i = 0; i <50000;i++)  
    {  
        ageArray[i]=i;  
        weightArray[i]=i;
        nameArray[i] = "Test";
    }  
    ARRAY oraAge = new ARRAY(ageCollection,conn,ageArray);  
    ARRAY oraWeight = new ARRAY(weightCollection,conn,weightArray);  
    ARRAY oraName = new ARRAY(nameCollection,conn,nameArray);    
    
    CallableStatement statement = conn.prepareCall("{CALL insert_new_cat(?,?,?)}";   
    
    statement.setObject(1,oraAge);
    statement.setObject(2,oraWeight);  
    statement.setObject(3,oraName);  
    statement.execute();  
    conn.commit();  
    

    SQL procedure:

    CREATE OR REPLACE PROCEDURE  INSERT_NEW_CAT (age age, weight weight, name name)  
    AS
    BEGIN  
        forall i in 1..age.last  
            insert into cats(id,age,weight,name)  
            vales(cat_sequence.nextval,age(i),weight(i),name(i);  
    END INSERT_NEW_CAT;
    

    Of importance to note the line (age age) refers to the data type of age that I created in the oracle database. By implementing the above I was able to improve inserts on a fully indexed table to ~45000 a second. On a non-indexed table this value becomes ~70000 per second.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following SQL Server stored procedure : BEGIN TRAN CREATE TABLE #TempTable
Hi I have following sql statement that gives me the the first_name and total
I have the following SQL Server query: SELECT area FROM places WHERE REPLACE(area,'-',' ')
I have an anonymous pl/sql block with a procedure declared inside of it as
I have an ASP.Net application with the following code: try { sql = new
If I have the following SQL block (in SQL SERVER 2008 R2): BEGIN BEGIN
I have a stored procedure that performs a bulk insert in a table. I
I have following SQL statementL: select DATE(bla), count(*) from tableA group by DATE(bla) UNION
I have following SQL query SELECT TOP 10000 AVG(DailyNodeAvailability.Availability) AS AVERAGE_of_Availability FROM Nodes INNER
I have the following SQL snippet within a select statement: CASE WHEN wot.id LIKE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.