我真的不知道我在這裏做錯了什麼。MySQL DECLARE/SELECT INTO語法錯誤?
Routine Name: procInsertName
Type: PROCEDURE
Parameters: IN Name VARCHAR 30 Charset
DECLARE tempNameID INT;
SELECT nameID
INTO tempNameID
FROM name
WHERE value = @Name;
IF tempNameID IS NULL THEN
INSERT INTO name (value)
VALUES (@Name);
END IF;
Is deterministic: unchecked
Definer: <blank>
Security type: DEFINER
SQL data access: CONTAINS SQL
Comment: <blank>
我走出來的一個錯誤:
One or more errors have occurred while processing your request:
The following query has failed: "CREATE PROCEDURE `procInsertName`(IN `Name` VARCHAR(30)) NOT DETERMINISTIC CONTAINS SQL SQL SECURITY DEFINER DECLARE tempNameID INT;
SELECT nameID
INTO tempNameID
FROM name
WHERE value = @Name;
IF tempNameID IS NULL THEN
INSERT INTO name (value)
VALUES (@Name);
END IF;"
MySQL said: #1064 - 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 'DECLARE tempNameID INT;
SELECT nameID
INTO tempNameID
FROM name
WHERE valu' at line 1
任何幫助,將不勝感激,我已經花了近30分鐘線上看四周,找不到任何東西。謝謝。
您沒有將DECLARE初始化爲一個值,這可能是原因。例如,'DECLARE tempNameID INT unsigned DEFAULT 1;' – ryekayo 2014-10-10 15:36:46
謝謝@ryekayo,但遺憾的是沒有做任何事情。 – XstreamINsanity 2014-10-10 15:43:16