【问题标题】:No Such Column error in views视图中没有此类列错误
【发布时间】:2012-06-06 14:23:17
【问题描述】:

我在 sqlite - android 中创建了两个视图,但是当我创建第二个视图时 我收到错误

没有这样的库:template_contact_info.tmp_text 作为文本和 template_contact_info.tmp_link 作为链接

即使这两个列都存在于 template_contact_info 并且 template_contact_view 已成功创建。但仍然不知道为什么我得到 No such column 错误。

这是视图的代码

第一次查看

db.execSQL("CREATE VIEW IF NOT EXISTS 

template_contact_info AS 

SELECT

template_info.tmp_text as tmp_text ,
template_info.tmp_link as tmp_link , 
template_info.tmp_id as temp_id , 
template_info.tmp_type as tmp_type , 
template_contact._id as _id  
from template_info , template_contact 

where  template_info.tmp_id = template_contact.tmp_id");

第二视图//这里出现错误

db.execSQL("CREATE VIEW IF NOT EXISTS 

template_contact_assign AS SELECT 

contact_info.c_number as number , 
contact_info.c_name as name ,  
contact_info.c_id as conid, 
contact_info._id as cid, 
template_contact_info.tmp_type as type , 
template_contact_info.temp_id as tempid ,
template_contact_info.tmp_text as text ,
template_contact_info.tmp_link as link 
FROM contact_info LEFT JOIN template_contact_info
ON contact_info._id = template_contact_info._id");

【问题讨论】:

  • 请发布您的选择查询...
  • 选择查询哪个表?
  • 查询你在哪里得到这个错误。
  • @Hunt 你是在第一个 db.execSQL 语句之后提交事务吗?如果不是,则该视图在 DBMS 上不存在,因此第二个会话将无法识别它(因为您正在视图之上创建视图)。
  • n 我将如何做到这一点,因为我没有提交任何交易

标签: android sql database sqlite


【解决方案1】:

//你想得到

template_contact.tmp_id

//创建时你使用temp_id而不是tmp_id

template_contact_info.temp_id

编辑:

数据库已经存在,因此您需要卸载/删除数据库以重新创建修改后的表。

通过命令实用程序'adb shellor via eclipse using the file explorer. The database resides in under'/data/data//databases'`删除数据库。

对于adb use rm <db_name>

【讨论】:

  • 但我在 template_contact_info.tmp_text 处出现错误,我已经将 template_contact.tmp_id 重命名为 temp_id 所以这不是问题
  • 卸载应用对我有帮助!!谢谢,请更新您的答案,以便我可以接受它
猜你喜欢
  • 1970-01-01
  • 2014-06-20
  • 2023-03-09
  • 1970-01-01
  • 2011-11-03
  • 2018-06-20
  • 1970-01-01
  • 1970-01-01
  • 2020-12-28
相关资源
最近更新 更多