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.
Related
By using input_data_1 parameter I'm able to pass only one database table as a input to stored procedure and I'm fitting the forecast model using R language.
I have to use more than one database table in my stored procedure, but I'm not able to do that.
I spent lot of time to solve this but I couldn't, furthermore I don't have enough knowledge on SQL.
Can anyone help me to solve this?
wanted to ask if there is any Table Value parameter equivalent in MySQL through c# ADO.Net.
aim is to send list of custom object to mysql stored procedure at once in an attempt to make the whole process a little more efficient.
any help appreciated
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
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.
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