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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:01:27+00:00 2026-05-27T04:01:27+00:00

I have 2 questions regarding performance of PL/SQL script when executing DML. Ofcourse the

  • 0

I have 2 questions regarding performance of PL/SQL script when executing DML. Ofcourse the EXECUTE IMMEDIATE is the slowest one thats why we have forall, bulk insert etc. My Questions are

  1. I have to manipulate data in 3 different tables. Table1 (insert data), Table2(update data) and Table3 delete data. All of these would be done based on the values fetched using a cursor. the question is what would be more efficient here?
    • Putting each of these statements in individual Forall block? i.e.
fetch cursor
loop
   forall loop for table 1
   forall loop for table 2
   forall loop for table 3
end loop

OR

  • a global loop and execute these statments in that loop i.e.
fetch cursor loop
    for i IN array.count 
    loop
       3 statements for DML
    end loop end loop

Now my second question

  1. what is the efficient way to delete records in loop? I fetched the values of the records to be deleted through the cursor. now what would be the efficient way to delete them?

P.S:
Execuse my formatting

  • 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-27T04:01:27+00:00Added an answer on May 27, 2026 at 4:01 am

    The most efficient approach would be to write three SQL statements, assuming the data fetched from the cursor is stable over the period of time that the procedure is running

    INSERT INTO table1( list_of_columns )
      <<your SELECT statement>>
    
    UPDATE table2
       SET (<<list of columns>>) = (<<your SELECT statement joined to table2>>)
     WHERE EXISTS( <<your SELECT statement joined to table2>> );
    
    DELETE FROM table3
     WHERE EXISTS( <<your SELECT statement joined to table3>> );
    

    If the SELECT statement will potentially return different results in each of the three DML statements, then it makes sense to accept the performance hit of using a cursor, bulk collecting the data into PL/SQL collections, and looping over the collections in order to ensure consistent results. If that’s what you’re doing, it will be more efficient to have three FORALL statements since that involves fewer context shifts between the SQL and PL/SQL engines.

    What is the efficient way to delete records in loop? I fetched the values of the records to be deleted through the cursor. now what would be the efficient way to delete them?

    I’m not sure I understand the question. Wouldn’t you just do a FORALL loop just as you would for an INSERT or an UPDATE

    FORALL i IN l_array.first .. l_array.last
      DELETE FROM some_table
       WHERE some_key = l_array(i);
    

    Or are you asking a different question?

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

Sidebar

Related Questions

Regarding to SQL performance. I have a scalar valued function for checking some specific
I have a question regarding performance of SQL Server. Suppose I have a table
I have two questions regarding Java web application deployment and its impact on performance.
I have couple questions regarding some C++ rules. Why am I able to call
I have several questions regarding filenames and the iPod Library. I understand I can
I actually have two questions regarding the same problem but I think it is
I actually have two questions regarding exception/error handling in the iPhone app that I
I have seen different questions regarding this, but I still find this topic to
I'm very new to TDD world. I have a few questions regarding TDD. Do
I have a couple of questions regarding VBScript and ASP Classic: What is the

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.