将数据插入contacts2.db

时间:2015-12-26 09:02:40

标签: sql sqlite insert

为什么raw_contacts出现错误?

错误:

  

的SQLiteManager:
  INSERT INTO" raw_contacts" VALUES(1,1,NULL,0,2,1,0,1,0,0,NULL,0,0,NULL,0,2147483647,' 09999999999'' 09999999999&#39 ;,20,NULL,' 0'' 09999999999''#' 208' 09999999999','# ',208,0,NULL,NULL,NULL,NULL); [没有这样的整理顺序:PHONEBOOK]
  例外名称:NS_ERROR_FAILURE
  异常消息:组件返回失败代码:0x80004005(NS_ERROR_FAILURE)[mozIStorageConnection.createStatement]

INSERT的SQL语句:

INSERT INTO "contacts" 
VALUES(1, 1, NULL, NULL,  NULL, 0, 0, 0, 0, 2147483647, 1, '0r1-1224142414221E16121C1C', NULL, 1448202599930);

INSERT INTO "data" 
VALUES(1, NULL, 5, 1, 0, 0, 0, 0, '09999999999', '2', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

INSERT INTO "default_directory" 
VALUES(1);

INSERT INTO "phone_lookup" 
VALUES(1, 1, '09999999999', '5502681');

INSERT INTO "raw_contacts" 
VALUES(1, 1, NULL, 0, 2, 1, 0, 1, 0, 0, NULL, 0, 0, NULL, 0, 2147483647, '09999999999', '09999999999', 20, NULL, '0', '09999999999', '#', 208, '09999999999', '#', 208, 0, NULL, NULL, NULL, NULL);

INSERT INTO "search_index" 
VALUES(1, NULL, NULL, '09999999999');

INSERT INTO "visible_contacts" 
VALUES(1);

请帮助我:((

抱歉。我的英语不好。

结构raw_contacts:

CREATE TABLE raw_contacts 
(
    _id INTEGER PRIMARY KEY AUTOINCREMENT,
    account_id INTEGER REFERENCES accounts(_id),
    sourceid TEXT,
    raw_contact_is_read_only INTEGER NOT NULL DEFAULT 0,
    version INTEGER NOT NULL DEFAULT 1,
    dirty INTEGER NOT NULL DEFAULT 0,
    deleted INTEGER NOT NULL DEFAULT 0,
    contact_id INTEGER REFERENCES contacts(_id),
    aggregation_mode INTEGER NOT NULL DEFAULT 0,
    aggregation_needed INTEGER NOT NULL DEFAULT 1,
    custom_ringtone TEXT,
    send_to_voicemail INTEGER NOT NULL DEFAULT 0,
    times_contacted INTEGER NOT NULL DEFAULT 0,
    last_time_contacted INTEGER,
    starred INTEGER NOT NULL DEFAULT 0,
    pinned INTEGER NOT NULL DEFAULT 2147483647,
    display_name TEXT, display_name_alt TEXT,
    display_name_source INTEGER NOT NULL DEFAULT 0,
    phonetic_name TEXT, phonetic_name_style TEXT,
    sort_key TEXT COLLATE PHONEBOOK,
    phonebook_label TEXT,
    phonebook_bucket INTEGER,
    sort_key_alt TEXT COLLATE PHONEBOOK,
    phonebook_label_alt TEXT,
    phonebook_bucket_alt INTEGER,
    name_verified INTEGER NOT NULL DEFAULT 0,
    sync1 TEXT, sync2 TEXT, sync3 TEXT, sync4 TEXT 
)

2 个答案:

答案 0 :(得分:0)

将VALUES部分的单引号更改为双引号 看到这个链接 NS_ERROR_FAILURE in SQLite insert

答案 1 :(得分:0)

此表要求使用它的应用程序定义了名为“PHONEBOOK”的归类。

您必须定义此排序规则,或从表定义中删除COLLATE PHONEBOOK并使用不同的排序顺序。