简体   繁体   English

用于ODBC连接的SQL命令ISNULL

[英]SQL Command ISNULL for ODBC Connection

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). 我通过ODBC连接到OpenEdge DataServer(不是我们的产品,我们只是在访问他们的数据库,我几乎没有任何信息,并且当然也没有对方的帮助)。

Anyhow, I just need to execute a simple Select, add a couple of rows and I need the equivalent of an IsNull statement. 无论如何,我只需要执行一个简单的Select,添加几行,就需要一个IsNull语句。

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. 我四处查看他们误导性地称为“文档”的内容,但仅引用了SP_SQL_ISNULL,但我也无法使它起作用。 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 :) 我适合使用T-SQL,因此可以欣赏任何方向的任何指针,即使它只是带有TFM链接的RTFM :)

Thanks 谢谢

Thanks to Catalin and this question I got on the right track. 感谢Catalin和这个问题,我走上了正确的道路。 I kept thinking I needed a OpenEdge specific function but actually I needed to use only ODBC SQL syntax. 我一直认为我需要特定于OpenEdge的功能,但实际上我只需要使用ODBC SQL语法。

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 MSDN

Basically it will convert to 4 if the value is null (and therefore not convertable). 基本上,如果该值为null(因此不可转换),它将转换为4。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM