我想要做一個互動的存儲過程 我的意思是,在執行後用戶應輸入一個字「COUNT(*)」附近的語法錯誤?
我寫了這一點,但它不工作..
DELIMITER $$
DROP PROCEDURE IF EXISTS ric_forn$$
CREATE PROCEDURE ric_forn (IN nome_forn VARCHAR(100) , OUT msg VARCHAR(100))
BEGIN
DECLARE num_rec INT;
IF (nome_forn = '') THEN
SET msg = "Attenzione il nome inserito non è valido !";
END IF;
SELECT COUNT (*) INTO num_rec FROM Fornitori WHERE Des_Fornitore = nome_forn;
IF num_rec = 0 THEN
SET msg = "Nessun record trovato !";
ELSE
SELECT Id_Fornitore,Des_Fornitore,Ind_Fornitore WHERE Des_Fornitore = nome_forn;
SET msg = "Records trovati:";
END IF;
END$$
DELIMITER ;
我得到這個錯誤:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) INTO num_rec FROM Fornitori WHERE Des_Fornitore = nome_forn;
嗯,確實'SELECT COUNT(*)INTO num_rec FROM Fornitori WHERE Des_Fornitore = nome_forn;'從CLI工作? – 2011-09-22 21:42:42
我是一個初學者..你是什麼意思的CLI?...謝謝 – Roberto
好的抱歉,你的意思是從外殼..即使我註釋掉這一行東西不順利無論如何.. – Roberto