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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:37:49+00:00 2026-05-28T05:37:49+00:00

I am trying to solve this piece of code with a bulk insert or

  • 0

I am trying to solve this piece of code with a bulk insert or something else more effective but I am out of ideas. How would you approach this problem. Instead of looping so many times i would like to do it more effective in few calls. Please let me know how you would do? With code if possible! Thanx

LOOP
-- Fetch a row
IF DBMS_SQL.FETCH_ROWS(cursor_handle) > 0 THEN
    DBMS_SQL.column_value(cursor_handle, 9, cont_id); 
    DBMS_SQL.COLUMN_VALUE(cursor_handle, 3, proj_nr);  
    HTP.BOLD('ContractID: ' || cont_id || ' ProjectNR: ' ||  proj_nr);
    HTP.BR;
ELSE
    EXIT;
END IF;

-- delete the old list before saving a new one
IF sek_nr = 1 THEN
  EXECUTE IMMEDIATE 'DELETE FROM W_Contracts WHERE user_id = :n' USING CURRENTUSER;
END IF;

EXECUTE IMMEDIATE 'Insert into W_Contracts values(''' || currentUser || ''', '
                   || sek_nr || ', sysdate, ' || cont_id || ', '''
                   || proj_nr || ''')';

sek_nr := sek_nr + 1;
END LOOP;
  • 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-05-28T05:37:50+00:00Added an answer on May 28, 2026 at 5:37 am

    First off, it’s not clear to me why you’re using dynamic SQL rather than static SQL.

    IF sek_nr = 1 
    THEN
      DELETE FROM w_contracts
       WHERE user_id = currentUser;
    END IF;
    
    INSERT INTO w_contracts( <<list of columns>> )
      VALUES( currentUser, sek_nr, sysdate, cont_id, proj_nr );
    

    Next, it’s not obvious to me why you’re potentially doing a DELETE and then an INSERT if the SEK_NR is 1. It would likely be more efficient to do an UPDATE in that case. And once you’re doing an UPDATE and an INSERT, you can simplify that into a single MERGE statement.

    Next, if you use the DEFINE_ARRAY method in DBMS_SQL, you can do bulk fetches of data from your cursor. Of course, without seeing your cursor definition, I would be suspicious that it too was using dynamic SQL unnecessarily and that you could use a much simpler approach.

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

Sidebar

Related Questions

Trying to solve this problem . I would like to learn how the bootstrapper
I've been trying to solve this problem for a number of days now but
I'm trying to solve this problem, its not a homework question, its just code
I have been trying to solve this problem for a while, but couldn't with
I could solve this using loops, but I am trying think in vectors so
I am trying to load and save objects with this piece of code I
I'm trying out multithreading but I cant figure out why the the piece of
By trying to solve this problem , something made me wonder. Consider the following
I'm trying to solve this problem but it always fails the tests. here's my
I'm trying to solve this flickering problem on the iphone (open gl es game).

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.