0

这是我的进化1.sql

CREATE OR REPLACE FUNCTION update_changetimestamp_column()
RETURNS TRIGGER AS $$
BEGIN
  NEW.changetimestamp = now();
  RETURN NEW;
END;
$$ language 'plpgsql';

但是当我应用这种演变时,play-slick 给了我这个错误

we got the following error: ERROR: unterminated dollar-quoted string at or near "$$ BEGIN NEW.changetimestamp = now()" Position: 79 [ERROR:0, SQLSTATE:42601], while trying to run this SQL script:

知道发生了什么吗?我可以直接在 postgres 控制台上创建该功能

4

1 回答 1

1

嗨史蒂夫你解决了你的问题吗?

如果您查看 Play 的进化手册,您会发现以下内容:

Play 将您的 .sql 文件拆分为一系列以分号分隔的语句,然后对数据库逐个执行它们。因此,如果您需要在语句中使用分号,请输入 ;; 将其转义。代替 ;。例如,INSERT INTO punctuation(name, character) VALUES ('semicolon', ';;');

您的脚本应修改为:

CREATE OR REPLACE FUNCTION update_changetimestamp_column()
RETURNS TRIGGER AS $$
BEGIN
  NEW.changetimestamp = now();;
  RETURN NEW;;
END;;
$$ language 'plpgsql';
于 2016-10-12T16:46:34.813 回答