如何将存储过程从MS SQL转换为MySql

时间:2021-12-12 21:19:25

Please I have a problem when i try to write a stored procedure on MySql,

当我尝试在MySql上编写存储过程时,我有问题,

My Procedure on SQL Server is :

我在SQL Server上的过程是:

//// SQL Server ///

//// SQL Server ///

create Proc [dbo].[P_TestSup] @para1 int, @para2 bit output as  
begin
        select @para2= count(IdCV) from CommandeVente,Client where
      CommandeVente.IdClnCV=Client.IdCln and IdCln=@para1   
End

I Try to Write it on MySQL but it's Incorrect

我尝试在MySQL上写它但它不正确

Error: check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3

错误:检查与MySQL服务器版本对应的手册,以便在第3行的''附近使用正确的语法

////// MySql //////

////// MySql //////

CREATE PROCEDURE P_TestSup(IN para1 INT, OUT para2 bit) 
begin 
select count(commandevente.idcv) into para2 from commandevente,client 
   where commandevente.idclncv= client.idcln and client.idcln=para1;
End

1 个解决方案

#1


0  

Perhaps your problem is the lack of DELIMITER statement. And fix the JOIN syntax. And the type of the output parameter. Also, I would be careful about naming.

也许你的问题是缺少DELIMITER语句。并修复JOIN语法。和输出参数的类型。另外,我会注意命名。

Something like this:

像这样的东西:

DELIMITER $$

CREATE PROCEDURE P_TestSup(
    in_para1 INT,
    OUT out_para2 INT
) 
BEGIN 
    SELECT count(commandevente.idcv) into out_para2 
    FROM commandevente ce
         client c
         ON ce.idclncv = c.idcln ;
END;$$

DELIMITER ;

#1


0  

Perhaps your problem is the lack of DELIMITER statement. And fix the JOIN syntax. And the type of the output parameter. Also, I would be careful about naming.

也许你的问题是缺少DELIMITER语句。并修复JOIN语法。和输出参数的类型。另外,我会注意命名。

Something like this:

像这样的东西:

DELIMITER $$

CREATE PROCEDURE P_TestSup(
    in_para1 INT,
    OUT out_para2 INT
) 
BEGIN 
    SELECT count(commandevente.idcv) into out_para2 
    FROM commandevente ce
         client c
         ON ce.idclncv = c.idcln ;
END;$$

DELIMITER ;