Skip to Main Content
  • Questions
  • Inserting multiple rows from java to stored procedure

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Glen.

Asked: December 23, 2005 - 7:33 pm UTC

Last updated: December 24, 2005 - 9:08 am UTC

Version: 9.2.0

Viewed 1000+ times

You Asked

We are in the process of writting an application to record student grades from our web course management system to our Registrars student information system. The CMS connects to the Registrars SIS using JDBC across a fairly fast network, and submits the grades for each student by making a call to a stored procedure. The stored procedure will perform some sanity checks on the data before inserting it to the database. We are responsible for developing the stored procedure and also developing the java program on the CMS.

I'm looking for the options for sending the data from the CMS to the stored procedure. I can make individual calls to the stored procedure for each grade needing writing. Are there other options for sending a batch of students to the stored procedure? What are the performance characteristics of those other methods?

Thanks, Glen

and Tom said...

you can

a) use a global temporary table - the jdbc application would use BATCH inserts to put say 100 "entries" in there - then invoke the stored procedure to process them.

b) use collections (read about jpublisher) and have the jdbc application send "arrays" of inputs:

</code> https://docs.oracle.com#index-JPU <code>


I rather like option (A) - it is one of the times I myself have used global temporary tables...



Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Real Table

Ola, December 24, 2005 - 4:47 am UTC

Why not use a "real" table instead of a temporary table ?

From Restrictions on Temporary Tables
" Distributed transactions are not supported for temporary tables "
Can you explain why ?

//Ola

Tom Kyte
December 24, 2005 - 9:08 am UTC

why use a 'real' table that you would have to clean out yourself and has all of the baggage of real tables - when you don't have to?

That is a documented restriction on global temporary tables - just not supported. I don't always know "why", but I do "know that it exists"...


I suggested the global temporary table so as to avoid some redo generation, to make it so that I never accidently see someone elses rows, so that I never have to "clean out the table".

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library