播放Framework 2.0的演变并创建触发器 [英] Play framework 2.0 evolutions and create trigger

查看:91
本文介绍了播放Framework 2.0的演变并创建触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用Play 2.0.3创建此触发器.如果我手动运行它,它在MySQL中运行得很好,但是当尝试从Play运行它时,它会失败.

I have been trying to get this trigger created using Play 2.0.3. It runs perfectly fine in MySQL if I run it manually, but it fails when trying to run it from Play.

delimiter |
    create trigger company_updated before update on company
        for each row begin
            set new.updated = CURRENT_TIMESTAMP;
        end;
    |
delimiter ;

它引发的错误是这样的:

The error it throws is this:

我们收到以下错误:您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册,以在'delimiter |附近使用正确的语法.尝试运行此SQL脚本时,在第1行[ERROR:1064,SQLSTATE:42000]的每一行的公司更新之前,创建触发器company_updated,

We got the following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delimiter | create trigger company_updated before update on company for each row' at line 1 [ERROR:1064, SQLSTATE:42000], while trying to run this SQL script:

推荐答案

delimiter关键字不是SQL语句,仅在mysql命令行客户端中使用.

The delimiter keyword is not a SQL statement, it is only used in the mysql command line client.

尝试删除delimiter部分:

create trigger company_updated before update on company
    for each row begin
        set new.updated = CURRENT_TIMESTAMP;
    end;

但是正如您提到的,您可能会点击播放分号错误:(

But as you mentioned, you may hit a Play bug with the semi-colon :(

这篇关于播放Framework 2.0的演变并创建触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆