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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:19:53+00:00 2026-06-09T20:19:53+00:00

I have the following PL/SQL code which I am using for calling an API

  • 0

I have the following PL/SQL code which I am using for calling an API (provided by client)
in order to adjust accounts.

I would like to improve my code if there any short comings or better way or approach in writing this block.

P.S. Unfortunately our client is still using Oracle 8i for their product.

PLSQL Code

DECLARE
    v_account_id account_adjustments.account_id%TYPE;
    v_adj_no     account_adjustments.adj_no%TYPE;
    v_old_qty    product_warehouse.new_qty%TYPE;
    v_new_qty    product_warehouse.new_qty%TYPE;
BEGIN
    v_old_qty := NULL;
    v_new_qty := NULL;

    FOR acnt IN (SELECT *
                 FROM   temp_table a) LOOP
        SELECT a.new_qty
        INTO   v_old_qty
        FROM   product_warehouse a
        WHERE  ( a.product_no = acnt.product_no );

        Adjust_accounts (in_service_product_no => acnt.product_no,
                         in_service_qty => acnt.qty,
                         out_account_id => v_account_id,
                         out_adj_no => v_adj_no);

        SELECT b.new_qty
        INTO   v_new_qty
        FROM   product_warehouse b
        WHERE  ( b.product_no = acnt.product_no );

        INSERT INTO account_year_todate
                    (product_no,
                     account_id,
                     adj_no,
                     qty_bad,
                     qty_warehouse,
                     qty_factory)
        VALUES      ( acnt.product_no,
                     v_account_id,
                     v_adj_no,
                     acnt.qty,
                     v_old_qty,
                     v_new_qty );
    END LOOP;
EXCEPTION
    WHEN OTHERS THEN
      dbms_output.Put_line ('exceptions '
                            || SQLERRM);

      ROLLBACK;
END; 
  • 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-09T20:19:54+00:00Added an answer on June 9, 2026 at 8:19 pm

    Some things to change:

    • Replace SELECT * in the For loop cursor with the columns that you actually need.
    • Your exception block is what I call a silent killer. That’s a debugging nightmare because it does nothing except for suppress exceptions because you aren’t logging it, you’re not re-raising it – instead just redirecting all exceptions via put_line into a buffer, which isn’t visible at all, unless you’re running the program from a IDE which shows buffer output always, or via SQL*Plus. Change it to a proper logging system.
    • I have no idea what Adjust_accounts does – and you could probably reduce those 2 select statements and have the amounts returned using the stored procedure you’re calling?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following Uncle Bob's avice in Clean Code , I'd like to have no SQL
I have the following t-sql code which I have converted to c#. DECLARE @guidRegular
I have the following bit of code which runs a SQL statement: int rowsEffected
I have the following code which is working great for me. I am using
I have a question about the following code which I'm using in a prepare-execute
I have the following code which counts vehicles grouped by vehicle type. using (var
I have the following SQL code that runs against a Change Request database. Each
I have following tsql code in sql server 2008: declare @ID INT SET @ID
I have the following java code: import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement;
I have the following code: def add_record(self,values): self.sql.execute(INSERT INTO TEST VALUES (?,?) % values)

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.