%ODBCOUT(expression) %ODBCOUT expression
|expression||The expression to be converted. A field name, an expression containing a field name, or a function that returns a value in a convertible data type, such as DATE or %List. Cannot be a stream field.|
%ODBCOUT returns expression in the ODBC format after passing the value through the field or data type’s LogicalToOdbc method. The ODBC format is the format in which data can be presented via ODBC. This format is used when data is exposed to ODBC/SQL. The available formats correspond to those defined by ODBC.
%ODBCOUT is commonly used on a SELECT list select-item. It can be used in a WHERE clause, but this use is discouraged because using %ODBCOUT prevents the use of indexes on the specified field.
Applying %ODBCOUT changes the column header name to a value such as “Expression_1”; it is therefore usually desirable to specify a column name alias, as shown in the examples below.
Whether %ODBCOUT converts a date depends on the data type returned by the date field or function. %ODBCOUT converts CURDATE, CURRENT_DATE, CURTIME, and CURRENT_TIME values. It does not convert CURRENT_TIMESTAMP, GETDATE, GETUTCDATE, NOW, and $HOROLOG values.
%ODBCOUT is an InterSystems SQL extension.
For further details on display format options, refer to “Data Display Options” in the “InterSystems IRIS SQL Basics” chapter of Using InterSystems SQL.
The following example shows the default display format, the %ODBCIN, and the %ODBCOUT formats for the same field.
SELECT FavoriteColors,%ODBCIN(FavoriteColors) AS InVal, %ODBCOUT(FavoriteColors) AS OutVal FROM Sample.Person
SQL concepts: Data Types, Date and Time Constructs