Merging four stored procedures into one - sql-server-2008

I'm trying to call 3 other stored procedures within a "master" stored procedure and then return the combined results for all 4 stored procedures.
Is this possible?
And if so, I would appreciate some example sql code. The only way I could see this working is if the "master" stored procedure could somehow store the 3 partial result sets it obtains from the other stored procedures in variables. I'd appreciate the help on this!

Assuming you don't need to join the output of the child procedures together, and that the child procedures return resultsets using SELECT statements, this should just work without you needing to do any additional storing of result sets.
Basic example:
CREATE PROC up_sample
AS
EXEC up_proc1
EXEC up_proc2
EXEC up_proc3
GO

Related

How can I get the results of a stored procedure using SSIS?

I have stored procedure that will run a complex select statement and will show the results.
I need to use this stored procedure within a data flow. I tried to use the EXECUTE within OLEDB source but I got an error. I am guessing it's because of a large dataset? because I tried it with another SP that will give only 1 row and it worked!
so how can I get the results of the SP and use it in my data flow?
Thanks

MySQL Stored Proc Refactoring - Extract Method

I have some logic in a stored procedure (MySQL) that is calculating 8 variables that I now want to reuse this logic is another stored procedure. I want to 'extract method' this piece of logic in to a separate stored proc and then call it and store the results in the caller, in perhaps a temporary table. Does anyone know of a pattern to do this?
I've read up that you can can't store any results when you simply CALL proc_name(); etc, so I'm wondering what the most elegant way of doing this is?
Thanks.

Grouping SQL queries

Sometimes an application requires quite a few SQL queries before it can do anything useful. I was wondering if there is a way to send those as a batch to the database, to avoid the overhead of going back and forth between the client and the server?
If there is no standard way to do it, I'm using the python bindings of MySQL.
PS: I know MySQL has an executemany() function, but that's only for the same query executed many times with different parameters, right?
This process works best on inserts
Make all you SQL queries into Stored Procedures. These eventually will become child stored procedures
Create Master Store procedure to run all other Stored Procedures.
Modify master Stored procedure to accept values required by child Stored Procedures
Modify master Stored procedure to accept commands using "if" statements to know which
child stored procedures to run
If you need return data from Database use 1 stored procedure at the time.

How do I store and iterate over a result set in a MySQL Stored Proc?

I'm relatively new to MySQL stored procs, so I was hoping someone could help me out here. I want to call my stored proc (maybe pass in one IN param) and have it do the following:
SELECT some data
Iterate over the records
Perform some operations on a few of the fields in each record including some INSERTs in other tables based on the data it finds.
My problem is that I don't know how to store the SELECT data set and iterate the records. I know how to declare and set stuff like int and text, but not full data sets. How do I do this?
Thanks
Look into MySql Cursors
http://dev.mysql.com/doc/refman/5.0/en/cursors.html

how do I create a stored procedure from within a stored procedure

I would like to manage the deploy of stored procedures by first inserting them into a table, then, when it's time to deploy.... use a stored procedure to create all of the stored procedures. (Execute seems to be limited to CRUD)
This is not possible with MySQL. In stored procedures and functions you have even more restrictions in language use then in prepared statements.
The list of acceptable commands for prepared statements (see manual) does not include create procedure.
I'm not sure if this is what you looking for, but its has a good example and a reference at the bottom.
http://forums.mysql.com/read.php?98,219523,219787#msg-219787
Matthew H.