0
我忘記了放分隔符指令,一些分號並且使用了在mysql中無效的[select variable = field]這樣的tsl語法。
使用tsl語法時發生Mysql錯誤是[不允許從函數返回結果集]並且沒有多大幫助。
@AndreKR把它全部給我,謝謝。
我使用mysqlworkbench 5.2.30 CE。 成爲功函數:函數在返回bigint時抱怨[不允許從函數返回結果集]
delimiter //
CREATE FUNCTION nextval (seq_name varchar(100))
RETURNS bigint(20)
READS SQL DATA
NOT DETERMINISTIC
BEGIN
DECLARE workval bigint(20);
SELECT count(1) into workval
FROM tip_sequence
WHERE sequencename = seq_name;
IF workval <> 1 THEN
DELETE
FROM tip_sequence
WHERE sequencename = seq_name;
INSERT
INTO tip_sequence (sequencename, sequenceval, sequencestep)
VALUES (seq_name, 1, 1);
END IF;
SELECT sequenceval into workval
FROM tip_sequence
WHERE sequencename = seq_name;
UPDATE tip_sequence
SET sequenceval = sequenceval + sequencestep
WHERE sequencename = seq_name;
RETURN workval;
END//
delimiter ;
我很困惑..這應該是MySQL或TSQL?它不能同時存在。如果tsql,變量需要以'@'作爲前綴。 – deutschZuid