I have a non-trivial
SELECT statement and I don't want to write it twice (standard SW development considerations). I want to use the results in two stored procedures. I am imagining something like this:
CREATE PROCEDURE consumerProcedureA() BEGIN CALL supplierProcedure(); -- ** insert magic here ** END; CREATE PROCEDURE consumerProcedureB() BEGIN CALL supplierProcedure(); -- ** insert magic here ** END; CREATE PROCEDURE supplierProcedure() BEGIN SELECT field1, field2, field3, MESSYEXPR AS field4 FROM (complicated sub-SQL query) -- blah blah blah ; END;
Grant you, I could create a view to capture the common query, but is there a way to have a calling stored procedure access and process the result set returned by a called stored procedure?