我是 MySql 的新手。我创建了一个程序:
DELIMITER $$
CREATE PROCEDURE `sampledb`.`InsertSample`
(
IN aName VARCHAR(20),
IN aVersion VARCHAR(10),
IN pName VARCHAR(50),
OUT InsertStatus VARCHAR(30)
)
BEGIN
IF NOT EXISTS(SELECT st.AName FROM sampletable st WHERE st.AName = aName)
INSERT INTO sampletable(AName, AVersion, PName)
VALUES(aName, aVersion, pName)
SET InsertStatus = 'Success'
ELSE
SET InsertStatus = 'Already exists!'
END IF
END$$
DELIMITER $$;
我也尝试了其他插入方式:
INSERT INTO sampletable (aName, aVersion, pName)
这两次,我都收到了这个错误:
Error Code : 1064
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax ..
我正在使用 MySql 5.0.51b-community-nt