2017-10-08 73 views
0

請我有一個問題,當我嘗試寫MySql上的存儲過程,我如何可以轉換存儲過程從MS SQL到MySql

我的SQL Server上的程序是:

//// SQL服務器///

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 [email protected] 
End 

我試着寫一個關於MySQL但它是不正確的

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

//////的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 

回答

0

也許你的問題是缺乏DELIMITER聲明。並修復JOIN語法。輸出參數的類型。另外,我會小心命名。

事情是這樣的:

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 ; 
+0

對不起我的問題,需要一些編輯 時,我想添加像==條件> 和c.idcln = in_para1; 他們說;檢查與你的MySQL服務器版本相對應的手冊,在'ON ce.idclncv = c.idcln和c.idcln = in_para1; END '在行3個 –

+0

感謝您的幫助,我使用此代碼和它的工作===> ' DELIMITER $$ CREATE DEFINER ='root' @'localhost' PROCEDURE'P_TestSup'(在in_para1 INT,OUT out_para2 INT) BEGIN SELECT count(commandevente.idcv)into out_para2 FROM commandevente ce,client c where ce.idclncv = c.idcln and c.idcln = in_para1; END $$ DELIMITER; –

相關問題