Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database UNIX时间戳比较_Database_Sqlite_Android Sqlite - Fatal编程技术网

Database UNIX时间戳比较

Database UNIX时间戳比较,database,sqlite,android-sqlite,Database,Sqlite,Android Sqlite,我正在为数据库使用fallowing模式来存储消息传递线程 CREATE TABLE threads( _id INTEGER PRIMARY KEY AUTOINCREMENT, date_sent_or_received INTEGER, read INTEGER, count INTEGER, body TEXT, address TEXT, error_code INTEGER); 每当我向SMS表中插入值时,就会激活

我正在为数据库使用fallowing模式来存储消息传递线程

CREATE TABLE threads(
    _id INTEGER PRIMARY KEY AUTOINCREMENT, 
    date_sent_or_received INTEGER, 
    read INTEGER, 
    count INTEGER, 
    body TEXT, 
    address TEXT, 
    error_code INTEGER);
每当我向SMS表中插入值时,就会激活一个空闲触发器

CREATE TRIGGER update_thread_id AFTER INSERT ON sms
WHEN
0 <> (select count() from threads
      where length(address)>=length(new.address)
        and substr(address, length(address)-length(new.address)+1) like new.address)
BEGIN
UPDATE threads SET
    address = new. address
where substr(address, length(address)-length(new.address)+1) like new.address;

UPDATE threads SET
    date_sent_or_received=new.date_sent_or_received,
    read = new.read,
    body = new.body 
where date_sent_or_received<=new.date_sent_or_received
  and address like new.address;

UPDATE sms SET
    thread_id= (select _id from threads
                where address like new.address)
where _id = new._id;

UPDATE threads SET
    count = (select count() from sms 
             where thread_id=(select _id from threads 
                              where address like new.address))
where address like new.address;

END;
我遇到了一个问题陈述,只有当线程的内容比新线程的内容旧时,我才试图更改线程的内容。事情是这样的

UPDATE threads SET
    date_sent_or_received=new.date_sent_or_received,
    read = new.read,
    body = new.body 
where date_sent_or_received<=new.date_sent_or_received
  and address like new.address;
但是,它不起作用。即使新插入的行的时间戳更大,表的内容也保持不变,此触发器根据新添加的行更新地址

我将秒存储为整数。
你知道我哪里错了吗?

我不知道你问题的确切答案。但由于您的问题是关于查询的,如果您在SQLite中执行这些操作,请在SQliteBrowser或SQLiteManager中测试SQL语句。在这里,您可以了解数据库是如何对您的语句作出反应的