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

  • Home
  • SEARCH
  • 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 8770379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:33:01+00:00 2026-06-13T17:33:01+00:00

I am writing a complex Stored Procedure in ORacle that does several things, as

  • 0

I am writing a complex Stored Procedure in ORacle that does several things, as part of a Java program with JDBC.

First, it needs to perform a very complex SELECT to read information into a cursor, with each row of the cursor denoting a lineitem for an invoice. There are about 10 columns in the output cursor. For each row of the cursor, some but not all of the fields need to be inserted into another table (called LineItem), and in addition to this I need to take the total of all those rows in the cursor and create a parent row in an Invoice table.

Would it be easier to read the cursor back into the Java app, then iterate over its contents performing INSERTS as necessary, or is it possible to do all of this within the same Stored Procedure? I am thinking multiple stored procedures should be used to avoid complexity, but am not sure if this can be done and for it all to remain as part of one transaction.

I am trying to avoid creating a super complex Stored Proc, but don’t want a dreadful solution either.

Thanks

  • 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-13T17:33:02+00:00Added an answer on June 13, 2026 at 5:33 pm

    We too have a similar situation (processing invoices and their line items) and we do the following:

    1. Retrieve the line items in batches of 1000 (to not overwhelm the java program with too many items at the same time).
    2. Insert the record into LineItem table with the required columns from the line item record.
    3. Deduce the details for the header record while iterating through these records denoting the line item.
    4. At the end of processing all the line items in batches, insert the header record into the database.

    We use JPA (With hibernate) and Spring for this and all the above steps are performed in a single transaction.

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

Sidebar

Related Questions

I'm writing a C++ program which needs to be able to read a complex
I am writing a program that needs to read a set of records that
I'm writing a fairly complex stored procedure to search an image library. I was
Right now I am writing a program in OpenGl. I'm rendering some-what complex 3D
We run a website written in Java that uses JDBC with jTDS to access
I'm writing a C++ program that has a large number of classes. In my
I'm trying to write a stored procedure in SQL Server that will eliminate some
I'm writing a console application that does a good amount of data retrieval from
I'm writing a Risk-like board game in java. A feature is that players can
I am writing a class using Qt that needs to import a dictionary that

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.