Alex Duggleby
Alex Duggleby

Reputation: 8038

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).

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

Upvotes: 0

Views: 7226

Answers (2)

Alex Duggleby
Alex Duggleby

Reputation: 8038

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).

Upvotes: 5

Cătălin Pitiș
Cătălin Pitiș

Reputation: 14341

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.

Upvotes: 2

Related Questions