2012-11-06 55 views
1

我有我的SQL表的设置如下SQL UPDATE命令似乎并不奏效

create table contact(
id      bigint not null, 
first_name    varchar(255) not null, 
last_name     varchar(255) not null, 
phone      varchar(255) not null, 
email      varchar(255) not null, 
company     varchar(255) not null, 
external_access   varchar(255), 
online_status    varchar(12), 
constraint pk_computer primary key (id)); 

所以最初我输入数据值到表中,除了EXTERNAL_ACCESS和online_status.Then我尝试使用下面的函数更新online_status。

DB.withConnection { implicit connection => 
SQL(
    """ 
    update contact 
    set online_status = online 
    where email = {email} 
    """ 
    ).on(
     'email -> email 
     ).executeUpdate() 
    } 

所以在线状态更新之后,我尝试使用

select * from contact 

再次显示页面(上面的代码只是依据。实际显示功能的页面显示功能列表https://github.com/playframework/Play20/blob/master/samples/scala/computer-database/app/models/Models.scala

但是,online_status尚未更新。它继续不显示任何内容(在online_status列中)。有人可以帮我调试这个

回答

0

在线状态是一个varchar,problably您的查询应该是这样的:

""" 
    update contact 
    set online_status = 'online' 
    where email = {email} 
    """ 

注意“”来定义值的字符串。

此外,请确保您没有将旧值存储在缓存中。

+0

我试过'在线'的事情。没有区别。我如何确保将旧值存储在缓存中?有没有办法来检查,而不是让它发生(可能会像变化或什么..不是很确定) –