Requires Free Membership to View
Are you running the INSERT statement in the stored proc by using an explicit CURSOR? Are you looping through the cursor and performing a COMMIT every so often? These type of things can make your INSERT statement slow to a crawl.
Let's suppose that I have a simple INSERT statment, selecting data from a table, that I can run in SQL*Plus similar to the following:
INSERT INTO new_table SELECT * FROM old_table;To run this statement in a PL/SQL block, just do the same:
BEGIN INSERT INTO new_table SELECT * FROM old_table; END; /Now this PL/SQL block can be put into a stored procedure for quick recall. There is no need to use a cursor for this. Oracle will create an implicit cursor for you.
For More Information
- Dozens more answers to tough Oracle questions from Brian Peasland are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
This was first published in August 2002

Join the conversationComment
Share
Comments
Results
Contribute to the conversation