尝试在fts3中检索rowid时获取null(Getting null while trying to retrieve rowid in fts3)

编程入门 行业动态 更新时间:2024-10-28 14:33:08
尝试在fts3中检索rowid时获取null(Getting null while trying to retrieve rowid in fts3)

我坚持了最后5-6个小时。 没有什么工作。 我想获得对应于用户输入的查询的密钥,以便用户可以修改与该特定id相对应的数据。

这段代码中有什么不对的地方.. ??

db.execSQL("CREATE VIRTUAL TABLE " + DATABASE_TABLE + " USING fts3 (" + KEY_ID + " INTEGER PRIMARY KEY ASC, " + KEY_NAME + " TEXT NOT NULL, " + KEY_ADDRESS + " TEXT NOT NULL, " + KEY_CONTACT + " TEXT NOT NULL, " + KEY_BALANCE + " DOUBLE);");

我将这个KEY_ID列清空了。 我想得到这个id(使用像我们使用cursor.getString(int)的游标元素)让用户修改对应于所选id的值,所以我需要从某个地方获取id。 有没有办法调用fts3表的默认ID而不是使用别名?

I'm stuck at this for last 5-6 hours. Nothing is working. I want to get key corresponding to a user entered query so that user can modify the data corresponding to that particular id.

Is something wrong here in this code..??

db.execSQL("CREATE VIRTUAL TABLE " + DATABASE_TABLE + " USING fts3 (" + KEY_ID + " INTEGER PRIMARY KEY ASC, " + KEY_NAME + " TEXT NOT NULL, " + KEY_ADDRESS + " TEXT NOT NULL, " + KEY_CONTACT + " TEXT NOT NULL, " + KEY_BALANCE + " DOUBLE);");

I'm getting this KEY_ID column empty. I want to get this id (using cursor element like we use cursor.getString(int) ) to let the user modify the values corresponding to the chosen id so I need to get the id from somewhere. Is there any way to call the default ID of fts3 table rather than using an alias?

最满意答案

有没有办法调用fts3表的默认ID而不是使用别名?

问题是适配器中使用的游标必须具有名为_id的整数主键列,但_id不是SQLite的可识别别名。 所以不,你需要使用自己的别名。 您可以将docid as _id ,将rowid as _id等。


加成 由于我不相信您可以在CREATE VIRTUAL TABLE语句中改变docid INTEGER PRIMARY KEY列,因此您需要在SELECT语句中应用别名,例如:

SELECT docid as _id, bar FROM Foo WHERE bar MATCH 'John';

Is there any way to call the default ID of fts3 table rather than using an alias?

The problem is that Cursors used in Adapters must have an integer primary key column with the name _id, but _id is not a recognized alias by SQLite. So no, you need to use your own alias. You can use docid as _id, rowid as _id, etc.


Addition Since I don't believe you can alter the docid INTEGER PRIMARY KEY column in anyway inside the CREATE VIRTUAL TABLE statement, you will need to apply the alias in the SELECT statements, for example:

SELECT docid as _id, bar FROM Foo WHERE bar MATCH 'John';

                    
                     
          

更多推荐

本文发布于:2023-08-07 22:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466363.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:rowid   retrieve   null

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!