Mysql调用另一个存储过程的存储过程

时间:2022-02-21 10:05:03

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

很抱歉,信息不完整。这是我的两个sp: SP1 -

DELIMITER $$

分隔符$ $

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

如果存在SP1 $$ CREATE过程SP1(InputCustomerID int, InputOrderID int),则开始删除过程

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

//一些sql语句,最后将其放入数据库中的实际表tb1中。

END $$

结束$ $

DELIMITER ;

分隔符;

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

在SP2中,我为SP1的参数赋值。

DELIMITER $$

分隔符$ $

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

如果存在SP2 $ CREATE PROCEDURE SP2(),则删除过程

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

声明InputCustomerID int;声明InputOrderID int;声明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()));

从CustomerID不在的用户(从CustomerOrders中选择FK_CustomerID)和IsApproved = True和CustomerID IN(从CustomerProductOrders中选择FK_CustomerID,其中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());

从FK_CustomerID不在的订单(从prodcutorders中选择FK_CustomerID)和IsApproved = True和Date(OrderStartDate) = Date(Now();

Call SP1(InputCustomerID, InputOrderID);

调用SP1(InputCustomerID InputOrderID);

END $$

结束$ $

DELIMITER ;

分隔符;

2 个解决方案

#1


3  

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.

例如,我猜您一定在调用sp2,它调用sp1。其他任何东西都无法使sp1满足参数。

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.

你接着说sp2没有任何输入或输出参数。由于没有输出参数,我无法理解您如何期望从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.

我确信,“您不会得到输出,因为您没有设置任何输出”不是您想要的答案。您应该编辑您的问题,也许可以使用一些示例代码。

#2


1  

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

对不起,这段代码运行良好,还有其他语法错误。

Thanks for all your help.

谢谢你的帮助。

#1


3  

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.

例如,我猜您一定在调用sp2,它调用sp1。其他任何东西都无法使sp1满足参数。

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.

你接着说sp2没有任何输入或输出参数。由于没有输出参数,我无法理解您如何期望从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.

我确信,“您不会得到输出,因为您没有设置任何输出”不是您想要的答案。您应该编辑您的问题,也许可以使用一些示例代码。

#2


1  

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

对不起,这段代码运行良好,还有其他语法错误。

Thanks for all your help.

谢谢你的帮助。