Mysql Call Stored procedure from another stored procedure

18,940

Solution 1

I am sorry, this code works fine there was some other syntactical error.

Thanks for all your help.

Solution 2

Your question is very poorly worded, and it makes given a good answer very hard.

For example, I gather you must be calling sp2, which calls sp1. Anything else would make it impossible to feed sp1 the parameters.

You go on to say that sp2 doesn't have any input or output parameters. With no output parameters, I can't understand how you're expecting to see output from sp2.

I'm sure that, "You're not getting output because you didn't setup any output," is not the answer you wanted. You should edit your question, perhaps with some example code.

Share:
18,940
MySQL DBA
Author by

MySQL DBA

Hi! I am MySQL DBA. New to MySQL

Updated on July 18, 2022

Comments

  • MySQL DBA
    MySQL DBA almost 2 years

    I am sorry for the incomplete information. Here's my two sp's: SP1 -

    DELIMITER $$

    DROP PROCEDURE IF EXISTS SP1 $$ CREATE PROCEDURE SP1(InputCustomerID int, InputOrderID int) BEGIN

    // Some sql statements and finally put it into the actual table tb1 in the database

    END $$

    DELIMITER ;

    SP2 - In SP2 i am assigning input value of SP1's params.

    DELIMITER $$

    DROP PROCEDURE IF EXISTS SP2 $$ CREATE PROCEDURE SP2() BEGIN

    Declare InputCustomerID int; Declare InputOrderID int; Declare OrderStateDate Datetime;

    Select CustomerID into InputCustomerID From Cusomers Where CustomerID NOT IN (Select FK_CustomerID From CustomerOrders) and IsApproved = True and CustomerID IN (Select FK_CustomerID From CustomerProductOrders Where Date (OrderStartDate) = Date(Now()));

    Select OrderID into InputOrderID From CustomerOrders Where FK_CustomerID NOT IN (Select FK_CustomerID From CustomerProdcutOrders) and IsApproved = True and Date(OrderStartDate) = Date(Now());

    Call SP1(InputCustomerID, InputOrderID);

    END $$

    DELIMITER ;