Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / February 2006

Tip: Looking for answers? Try searching our database.

Stored Procedure Issue:Call Vs Loop

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Praveen_db2 - 10 Feb 2006 11:00 GMT
Hi All
db2 V 8.1.3 Windows
I have an application which processes some rows using an SP.There are 2
approaches to this issue.
1) I can call the SP once and pass all the rows together as CLOB.(Rows and
columns will be separated using special characters,say Rows by '~' and
Columns by'!').Inside the SP I can divide the rows one by one using a
loop.For each row I can use another while loop which will differentiate
the columns and assign it to some local variables.These variables may or
may not be passed in to another procedure based on some conditions.In this
case the loop will run (no. of rows* no. of columns) time.Also overhead of
using functions like POSSTR,SUBSTR etc is there.

2) Call the SP for each row and using a while loop break the columns and
assign them to variables.Rest of the functionality is same.

Now the simple question is ...which method is better...
Calling an SP one time and looping (rows*columns)inside it OR calling an
SP 'rows' times and looping inside it 'columns' time.

TIA
Praveen
--CELKO-- - 11 Feb 2006 19:37 GMT
Why not put the data in a query that works on a table, instead of using
either of these procedual approaches?  We do not use loops in a
declarative language.

Since you did not bother to post code or DDL, nobody can help you
figure out how to do this in a set-oriented fashion.
Knut Stolze - 13 Feb 2006 18:49 GMT
> Hi All
> db2 V 8.1.3 Windows
[quoted text clipped - 13 lines]
>
> Now the simple question is ...which method is better...

It depends.

> Calling an SP one time and looping (rows*columns)inside it OR calling an
> SP 'rows' times and looping inside it 'columns' time.

The first question is what kind of functionality do you want to implement
where this logic would be used.

Signature

Knut Stolze
DB2 Information Integration Development
IBM Germany

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.