SQLite 错误的原因:“错误#3132:数据类型不匹配。”在 Adob​​e AIR 中

发布于 2024-12-10 17:13:59 字数 799 浏览 0 评论 0原文

"SELECT * FROM locations 
 JOIN section_has_location ON locations.location_id = section_has_location.location_id 
 WHERE section_has_location.chapter_id =2 
   AND section_has_location.section_id=2"

我收到错误:

SQLError:“错误#3132:数据类型不匹配。”,详细信息:“无法将文本值转换为数值。”,操作:“执行”,detailID:“2300”

这些是表:

CREATE TABLE locations ( 
    location_id INTEGER,
    name        TEXT,
    mask_id     TEXT,
    x           REAL,
    y           REAL,
    content     TEXT,
    image_url   TEXT,
    type        TEXT 
);

CREATE TABLE section_has_location ( 
    chapter_id  INTEGER,
    section_id  INTEGER,
    location_id INTEGER 
);

如何修复查询不会导致错误?

更新:我导出了所有数据,并导入到一个新的干净数据库中。这似乎已经解决了该错误。

"SELECT * FROM locations 
 JOIN section_has_location ON locations.location_id = section_has_location.location_id 
 WHERE section_has_location.chapter_id =2 
   AND section_has_location.section_id=2"

I get the error:

SQLError: 'Error #3132: Data type mismatch.', details:'could not convert text value to numeric value.', operation:'execute', detailID:'2300'

These are the tables:

CREATE TABLE locations ( 
    location_id INTEGER,
    name        TEXT,
    mask_id     TEXT,
    x           REAL,
    y           REAL,
    content     TEXT,
    image_url   TEXT,
    type        TEXT 
);

CREATE TABLE section_has_location ( 
    chapter_id  INTEGER,
    section_id  INTEGER,
    location_id INTEGER 
);

How do I fix the query as to not cause the error?

update: I exported all the data, and imported into a new clean database. This seems to have solved that error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迷爱 2024-12-17 17:13:59

我刚刚获取了您的代码,创建了表并运行了查询,它工作正常。

我猜您所做的可能是编辑了其中一列的类型,但表尚未更新,请尝试在此处使用 sp_help tablename 或查看对象资源管理器(如果您使用的是 Management Studio)并检查列的数据类型,或者如果可以的话,删除两个表并重新创建它们可能会更容易

I just took your code, created the tables and ran the query and it works fine.

Im guessing what you have done is maybe edited the type of one of the columns but the table hasn't been updated, try sp_help tablenamehere or look in object explorer if you are using management studio and check what the datatype is of your columns, or if you can it may be easier to just drop both tables and recreate them

睡美人的小仙女 2024-12-17 17:13:59

我知道这是一个老问题,但今天我找到了新的答案。我遇到了完全相同的错误,结果发现我尝试更新的记录有一个整数列,其中包含字符串值“0”而不是整数 0。尽管我没有尝试设置该字段,但它导致了这个错误——当我手动修复该列的值时,错误消失了。

该字段包含字符串的原因是用于创建表的 DDL 将列定义为整数,但具有 DEFAULT '0' 子句而不是 DEFAULT 0。这意味着新插入的行将字符串值放入该列中。

I know this is an old question, but I found a fresh answer today. I was getting exactly the same error and it turned out that the record I was trying to update had an integer column which contained a string value '0' instead of an integer 0. Even though I wasn't trying to set that field, it caused this error -- and the error went away when I fixed that column's value manually.

The reason that field contained a string was that the DDL used to create the table defined the column as an integer but had a DEFAULT '0' clause instead of DEFAULT 0. That meant that newly inserted rows got the string value put into the column.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文