Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Proc Question

Status
Not open for further replies.

eveCalypso

Programmer
Apr 29, 2003
134
GB
Hello,
I need to call quite a few stored procedures. Had a look at a few examples re passing parameters etc. and everyone seems to keep recreating connection, command and parameter objects when calling these proc's.
Is there a reason why I can not write a generic runProcedure function for this purpose?

Off the top of my head it will probably need to take the stored proc name and an array of Parameters...
and maybe return a resultset?

Is this standard practise or am I missing something?? (and that could well be!)
EvE
 
Each stored procedure has its own set of Paramters, so there is really no shortcut for the paramters. As for the connection, you could create a public connection in the standard module and use it, but then you need to make sure that it gets closed and destroyed at some point. I don't see any advantage to generalizing in a function as you seem to suggest.
 
Good day,

Thank you for your opinion - asking and trying are the only two ways I will ever learn!

I have actually tried it - and I think it works nicely. As for advantages, well, maybe not too many, except that I don't have to think about connections etc everytime I want to run a stored procedure - I just setup and send my required parameters - also, the function handles the creation and cleaning up of the connection(s), command(s) and parameter(s).

I suppose if accessing Stored Procedures should ever change in future, then only will I see the real benefit :)

Regards,
EvE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top