我想将信息从carti插入domeniu但我收到错误消息。
CREATE TRIGGER trigger_UpdateItemDetails ON carti
FOR INSERT AS
BEGIN
INSERT INTO
domeniu
(
cod_d,
materia,
result
)
SELECT
id
domeniu
nr_exemplare
FROM
carti
END
错误消息:#1064 - 您的SQL语法出错;校验 与您的MySQL服务器版本对应的手册 语法使用附近' ON结果FOR INSERT AS BEGIN INSERT INTO domeniu ('第1行
答案 0 :(得分:1)
问题是int min = 2;
int max = 26;
int count = 10;
double inc = (max - min) / (double) (count - 1);
int[] weeks = new int[count];
double init = min;
for (int i = 0; i < count; i++) {
weeks[i] = (int) Math.round(init);
init += inc;
}
System.out.println(Arrays.toString(weeks));
。它应[2, 5, 7, 10, 13, 15, 18, 21, 23, 26]
。检查 MySQL Documentation是否有FOR INSERT AS
语法。看起来你混淆了BEFORE INSERT AS
语法。 CREATE TRIGGER
是MSSQL语法。
SQL Serer
答案 1 :(得分:0)
您应该使用以下命名约定命名触发器:
(BEFORE | AFTER)_tableName_(INSERT| UPDATE | DELETE)
例如after_tableName_insert
请参阅以下教程以创建触发器。 http://www.mysqltutorial.org/mysql-trigger-implementation.aspx