-3

I am writing a report generation program in Java, with oracle DB. I have a stored procedure, that will retrieve one value at a time. From my Java Program I am calling the procedure repeatedly. In extreme case, I have to call the procedure 60,000 times. But it shows problems like, wrong value is returned after a specified calls (like 300 calls). kindly tell me how to sort out this. Thanks.

  • 2
    Given that we don't know what your code does, what the tables look like, what your data is, what your expected results are, and what the results are that you're getting might be, it's very difficult to advise you on what the issue might be. Please edit your question and include the above information, and perhaps once it's answerable it will be re-opened. Thanks. – Bob Jarvis - Слава Україні Jun 24 '18 at 10:44
  • *'I have a stored procedure, that will retrieve one value at a time. '* And that's your mistake right there. Databases scale well when used properly, and properly means **set-based operations**. – APC Jun 24 '18 at 13:18

1 Answers1

2

Its not a good practice to call DB with such high frequency. You can use cursor in your stored procedure and fetch the required records at once. Check the link for reference Cursors in Oracle Stored Procedure

  • Thanks for the reply. Actually I need to pass 5 parameters(including an array of string) and get a result set from the procedure. Kindly advice me how to tackle this requirement. – Arun K GOVIND Jun 24 '18 at 06:58
  • 1
    Parameter count does not matter here. For basic code example, [Check this link](https://www.mkyong.com/jdbc/jdbc-callablestatement-stored-procedure-cursor-example/) – Fahad Shakeel Jun 24 '18 at 07:05