Home » SQL & PL/SQL » SQL & PL/SQL » Select Subquery vs For Loop
Select Subquery vs For Loop [message #41766] Thu, 30 January 2003 07:53 Go to next message
Michele
Messages: 77
Registered: December 2000
Member
I have a question in regards to what is the best approach.
I have to write a stored procedure that takes all the data from 5 tables and insert all records into 1 table.
My first thought was to write a stored procedure that looks like this:
insert into x
(select....)
Now the subquery is about 25 lines long. It entails getting data from about 5 different tables and using the Decode statement.

Or should my approach be to write For Loops for each table where I loop through each table and insert the record into table x.

Any thoughts would be appreciated. Thanks.
Re: Select Subquery vs For Loop [message #41767 is a reply to message #41766] Thu, 30 January 2003 08:34 Go to previous message
Jon
Messages: 483
Registered: May 2001
Senior Member
Doing it in SQL is likely to be more efficient. Doing it in PL/SQL with a FOR LOOP may be easier to read and therefore maintain.
Previous Topic: SQL Plus
Next Topic: CONTAINS Query
Goto Forum:
  


Current Time: Fri Jan 16 08:46:57 CST 2026