用于 ODBC 连接的 SQL 命令 ISNULL

发布于 2024-08-08 03:00:38 字数 349 浏览 4 评论 0原文

我通过 ODBC 连接到 OpenEdge DataServer(不是我们的产品,我们只是访问他们的数据库,我几乎没有任何信息,当然也没有来自另一方的帮助)。

无论如何,我只需要执行一个简单的 Select,添加几行,并且需要相当于 IsNull 语句。

基本上我想执行

SELECT ISNULL(NULL,'test')

此操作因语法错误而失败。我查看了一些他们误导性地称为“文档”的东西,但只有对 SP_SQL_ISNULL 的引用,但我也无法让它工作。我适合 T-SQL,所以任何方向的指针都会受到赞赏,即使它只是一个带有 TFM 链接的 RTFM :)

谢谢

I'm connected to an OpenEdge DataServer via ODBC (not our product, we are just accessing their database, I hardly have any information and certainly no help from the other side).

Anyhow, I just need to execute a simple Select, add a couple of rows and I need the equivalent of an IsNull statement.

Basically I'd like to execute

SELECT ISNULL(NULL,'test')

This fails with a Syntax Error. I've looked around at something they misleadingly call a "documentation" but there are only references to SP_SQL_ISNULL but I can't get that to work either. I'm fit in T-SQL, so any pointers in any direction appreciated, even if it's just a RTFM with a link to TFM :)

Thanks

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

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

发布评论

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

评论(2

青衫负雪 2024-08-15 03:00:38

感谢 Catalin 和这个 问题 我走上了正确的道路。我一直认为我需要 OpenEdge 特定功能,但实际上我只需要使用 ODBC SQL 语法。

要了解什么,

ISNULL(col,4) 

您可以使用

COALESCE(col,4) 

“返回具有最高数据类型优先级的表达式的数据类型。如果所有表达式都是不可空的,则结果将被键入为不可空的。”MSDN

基本上,如果值为 null(因此不可转换),它将转换为 4。

Thanks to Catalin and this question I got on the right track. I kept thinking I needed a OpenEdge specific function but actually I needed to use only ODBC SQL syntax.

To get what

ISNULL(col,4) 

does you can use

COALESCE(col,4) 

which "returns the data type of expression with the highest data type precedence. If all expressions are nonnullable, the result is typed as nonnullable."MSDN

Basically it will convert to 4 if the value is null (and therefore not convertable).

⒈起吃苦の倖褔 2024-08-15 03:00:38

我不是 100% 确定,但我认为 ODBC 驱动程序需要有效的 SQL 语句,而不是 DBMS 特定的 SQL 语句,就像您提供的那样。

I am not 100% sure, but I think ODBC driver expects a valid SQL statement, and not an DBMS specific SQL statement, like the one you provided.

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