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 9037055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:09:21+00:00 2026-06-16T09:09:21+00:00

I have the following set of TYPE, PROCEDURE and Java code. I am able

  • 0

I have the following set of TYPE, PROCEDURE and Java code. I am able to call the stored procedure successfully but i have to append the objects one after the other. I want the process to be happening at one shot as i am dealing with over 50K+ records. Can anyone please let me know what changes needs to be done so that i can send the entire list at one. The code can be found below.

TYPES: 
    CREATE OR REPLACE TYPE CER_GL_ENTRY_TYPE AS OBJECT
                      (idKey NUMBER(10)  );

    CREATE or REPLACE TYPE CER_GL_ENTRY_TYPE_LIST AS TABLE OF  CER_GL_ENTRY_TYPE;

PROCEDURE:

    CREATE OR REPLACE PROCEDURE GL_PROCESS_BULK_ENTRIES (
       p_array    IN     CER_GL_ENTRY_TYPE_LIST ,p_status      OUT VARCHAR2)
    AS
       v_count      NUMBER(5);
       row_detail   CER_GL_ENTRY_TYPE;
    BEGIN
       --p_arr_int := NEW array_int ();
       --p_arr_int.EXTEND (10);
       --len := p_array.COUNT;
       v_count := 0;

       FOR i IN 1 .. p_array.COUNT
       LOOP
          row_detail := p_array (i);
          DBMS_OUTPUT.put_line('hello');
          DBMS_OUTPUT.put_line (row_detail.idKey);
          --p_arr_int (i) := v_count;
          v_count := v_count + 1;
          p_status := 'true';
       END LOOP;

       DBMS_OUTPUT.put_line (v_count);
       DBMS_OUTPUT.put_line (p_status);
    EXCEPTION
       WHEN OTHERS
       THEN
          -- handle errors here...
          DBMS_OUTPUT.put_line ('Error: ' || SUBSTR (1, 255, SQLERRM));
    END;
    /

Java Bean:

    import java.sql.SQLData;
    import java.sql.SQLException;
    import java.sql.SQLInput;
    import java.sql.SQLOutput;

    public class SampleListenerBean implements SQLData
    {
        private String sql_type="CER_GL_ENTRY_TYPE";

        private int id;

        public SampleListenerBean() {

        }

        public SampleListenerBean(String sqlType, int id) {
            this.sql_type = sqlType;
            this.id = id;
        }




        public int getId() {
            return id;
        }
        public void setId(int id) {
            this.id = id;
        }


        public String getSQLTypeName() throws SQLException {
            return sql_type; 
        }

        public void readSQL(SQLInput stream, String typeName) throws SQLException {
            sql_type = typeName;

            id = stream.readInt();
        }

        public void writeSQL(SQLOutput stream) throws SQLException {
            stream.writeInt(id);
        }
    }

Main class: 

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.List;

import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;

public class StProcExample {



    public static void main(String args[]){
            Connection con=null;
            try{
                 DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver ());
            con = DriverManager.getConnection("jdbc:oracle:thin:@******:1521: TUW1", "*******", "*********");
            String query = "{call GL_PROCESS_BULK_ENTRIES(?,?)}";


            CallableStatement cs = con.prepareCall(query);
            ArrayDescriptor des = ArrayDescriptor.createDescriptor("CER_GL_ENTRY_TYPE_LIST", con);

            List<SampleListenerBean> sampleLst = new ArrayList<SampleListenerBean>();

            SampleListenerBean bean = null;

            for (int i = 0; i < 20; i++) {
                bean = new SampleListenerBean("CER_GL_ENTRY_TYPE",i);
                sampleLst.add(bean);
            }


            SampleListenerBean emp=new SampleListenerBean("TS.TEST_EMP_OBJ",234);
            SampleListenerBean emp1=new SampleListenerBean("TS.TEST_EMP_OBJ",235);
            Object[] employees= new Object[]{emp,emp1};
            Object[] employees= new Object[]{sampleLst};
            ARRAY a = new ARRAY(des, con, employees);
            cs.setObject(1, (Object)a);
            cs.registerOutParameter(2, Types.VARCHAR);
            cs.execute();

            String status = cs.getString(2);

            System.out.print("The status is " + status);
            if (cs != null) {
                cs.close();
             }
            }
            catch(SQLException e){
                e.printStackTrace();
            }


        }

    }

I want is the replacement for the following piece of code

    SampleListenerBean emp=new SampleListenerBean("TS.TEST_EMP_OBJ",234);
    SampleListenerBean emp1=new SampleListenerBean("TS.TEST_EMP_OBJ",235);
    Object[] employees= new Object[]{emp,emp1};

    ARRAY a = new ARRAY(des, con, employees);
    cs.setObject(1, (Object)a);

Instead of setting each object separately, i want to directly use sampleLst instead of the Object array “employees”. When i deal with 50K+ objects i cannot keep adding them to the object[]. i will run into heap problems as well. Can anyone please help me out here?

  • 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-16T09:09:23+00:00Added an answer on June 16, 2026 at 9:09 am

    I would use a simpler table type:

    CREATE OR REPLACE TYPE NUM_ARRAY AS TABLE OF NUMBER;
    

    And then somewhat simplify the stored procedure:

    CREATE OR REPLACE PROCEDURE GL_PROCESS_BULK_ENTRIES (
       p_array    IN     NUM_ARRAY,
       p_status   OUT    VARCHAR2)
    IS
    ...
    

    You then create an array of Integer that will easily fit in memory:

    Integer[] idArray = new Integer[50000];
    
    // fill the array of integers here
    for (int i = 0; i < idArray.length; i++)
        idArray[i] = ....;
    
    ARRAY a = new ARRAY(des, con, idArray);
    cs.setObject(1, (Object)a);
    

    There’s no need to create any heavy-weight beans just to pass a list of IDs.

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

Sidebar

Related Questions

In my servlet I have the following code: response.setContentType(application/json);//set json content type PrintWriter out
I have the following code in one of my Sql (2008) Stored Procs which
I have the following stored procedure : SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON
I have the following piece of code within my stored procedure , I know
I have the following code set up in my Startup IDictionary<string, string> properties =
I'm using entity framework 4. I have a stored procedure that just updates one
I have written the following stored procedure that uses a Date Dimension table to
I have written following stored procedure. If I don’t use IF ELSE block Order
I have a procedure in Sybase with the following code. begin transaction get_virtual_acc UPDATE
I have the following code which is working, but I don't understand it 100%

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.