2012-11-06 53 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

我試過'在線'的事情。沒有區別。我如何確保將舊值存儲在緩存中?有沒有辦法來檢查,而不是讓它發生(可能會像變化或什麼..不是很確定) –