使用 CASE 的 Interbase SQL SELECT 查询
我正在针对 .gdb 文件运行以下查询:
SELECT CASE USERS.USERID WHEN 1 THEN 'God' ELSE 'Somebody else' END FROM USERS;
但是,针对 .ib 文件运行基本相同的查询,我得到“第 1 行错误” 动态 SQL 错误,SQL 错误代码 = -104,令牌未知 - 第 1 行,字符 17"。它似乎无法识别 CASE USERS.USERID
部分。在 IBConsole 中,.ib 文件正在运行 SQL 方言 3,而 .gdb 文件正在运行方言 1。.ib 文件和 .gdb 文件之间有什么区别?
I'm running the following query against a .gdb-file:
SELECT CASE USERS.USERID WHEN 1 THEN 'God' ELSE 'Somebody else' END FROM USERS;
However, running essentially the same query against a .ib-file, I get "Error at line 1
Dynamic SQL Error, SQL error code = -104, Token unknown - line 1, char 17". It seems it doesn't recognize the part CASE USERS.USERID
. In IBConsole, the .ib-file is running SQL dialect 3, while the .gdb-file is running dialect 1. Does this matter? What's the difference between a .ib-file and a .gdb-file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.gdb
和.ib
只是文件扩展名。它们不会影响任何事情。我猜这里的问题是区分大小写。根据 SQL 标准的“分隔标识符”功能,如果您在创建表时使用双引号,即:
...则标识符区分大小写。完成此操作后,无论何时对表执行任何操作,都必须始终使用 (1) 分隔符(双引号)和 (2) 正确的大小写。
是的,很烦人,但是 SQL 标准需要它。 SQL Dialect 3 在执行 SQL 标准方面更加严格,包括分隔标识符。
为了解决这个问题,创建表时不要使用双引号,除非您确实需要此“功能”。
.gdb
and.ib
are juast file extensions. They don't affect anything.I'm guessing the problem here is case sensitivity. Per the "delimited identifier" feature of the SQL standard, if you use double quotes when you create the table, i.e.:
...then the identifier is case-sensitive. Having done this, you must therefore always use (1) delimiters (double quotes) and (2) the correct case whenever you do anything with the table.
Annoying, yes, but the SQL Standard requires it. SQL Dialect 3 is much more strict about enforcing the SQL Standard, including delimited identifiers.
To get around this, don't use double quotes when you create the table unless you actually want this "feature."