在 sqlite 中创建触发器的语法错误
Syntax error in creating trigger in sqlite
以下代码在 SQLite 中导致语法错误。
我想这一定很简单,但我看不到。
我有两个 tables,页面和项目,通过文本代码链接。当此代码在页面 table 中更改时,我希望它也在项目 table 中更改。
SQLite版本比较老,3.7.7.1,但是我在版本历史上没有看到过这样的问题。这发生在 Windows,PHP 5.3.1.
CREATE TABLE IF NOT EXISTS "efpage" ( "pageid" integer NOT NULL PRIMARY KEY, "psite" text NULL, "pgcode" text NULL );
CREATE TABLE IF NOT EXISTS "efitem" ( "itemid" integer NULL PRIMARY KEY , "isite" text NULL, "ititle" text NULL, "inpage" text NULL);
DROP TRIGGER IF EXISTS update_pagecode;
CREATE TRIGGER update_pagecode AFTER UPDATE OF pgcode ON efpage
BEGIN
UPDATE efitem SET inpage = new.pgcode WHERE inpage = old.pgcode;
END;
产生的错误是
"pgcode" 附近的错误:语法错误。
尝试不同的东西,我看到语法错误在 "old.pgcode;"
之后
如 CL 所示,
这与 SQLite 的版本有关。
我在 windows 上使用与 PHP 捆绑在一起的 SQLite。
我的下一个(已回答)问题是:
How to update the SQLite version bundled with PHP
以下代码在 SQLite 中导致语法错误。 我想这一定很简单,但我看不到。
我有两个 tables,页面和项目,通过文本代码链接。当此代码在页面 table 中更改时,我希望它也在项目 table 中更改。
SQLite版本比较老,3.7.7.1,但是我在版本历史上没有看到过这样的问题。这发生在 Windows,PHP 5.3.1.
CREATE TABLE IF NOT EXISTS "efpage" ( "pageid" integer NOT NULL PRIMARY KEY, "psite" text NULL, "pgcode" text NULL );
CREATE TABLE IF NOT EXISTS "efitem" ( "itemid" integer NULL PRIMARY KEY , "isite" text NULL, "ititle" text NULL, "inpage" text NULL);
DROP TRIGGER IF EXISTS update_pagecode;
CREATE TRIGGER update_pagecode AFTER UPDATE OF pgcode ON efpage
BEGIN
UPDATE efitem SET inpage = new.pgcode WHERE inpage = old.pgcode;
END;
产生的错误是 "pgcode" 附近的错误:语法错误。
尝试不同的东西,我看到语法错误在 "old.pgcode;"
之后如 CL 所示,
这与 SQLite 的版本有关。 我在 windows 上使用与 PHP 捆绑在一起的 SQLite。
我的下一个(已回答)问题是:
How to update the SQLite version bundled with PHP