Home

Getting Started

Utilities

Indexing

Omnidex

Development

Tutorials

Quick Links

 

sectionpage

ODXSQL - Commands - SET Options

Example

SET

 

ODXSQL

Special Characters

System Commands

Getting Help

Commands

 

CHAR

CHAR [AUTO | n]

CHAR=AUTO - returns all data back in CHARACTER data type, however it sets the size on a per-column basis to the smallest size that can safely return all possible values.

CHAR=n - returns all data back in CHARACTER data type and sets the buffer size to length n.

Converts binary data to character format, where n is the length of the converted character data. The default is AUTO.

CHAR can also be set in:

  • the options parameter of an OmniAccess API function
  • in the WITH clause of a SQL statement
  • in a SQL SET statement

If the CHAR option is passed to oaexecsql in the options parameter, it is passed to the underlying OmniAccess function. For example:

oaexecsql (cursor, "CHAR=AUTO", status, "SELECT * FROM ORDERS WHERE STATUS='BACK'")

In this example, the CHAR=AUTO option is passed to oaselect where the select statement will actually be processed.

The CHAR option automatically converts between alphanumeric and numeric data, thus eliminating any concern for byte-ordering and integer conversion across hardware platforms.

For example, when a client application on a PC requests numeric data using the CHAR, OmniAccess automatically converts the data from its numeric format to character data.

Conversely, when a client application sends information to a server, the character representation of the number is converted to a numeric type and byte order appropriate for the server operating system.

When using the CHAR option, the buffer must reflect the length of the ASCII character representation, not its binary storage format, and should be padded with blanks up to length n.

The CHAR option supports ASCII representations of numeric values that contain a leading + or -. It also supports exponential values, like 6.02e23, for numeric columns defined as TYPE FLOAT.

Character representations of floating point data may lose precision.

 

Example

CHAR can be passed in a SQL SET statement, in the options parameter of an OAAPI function, or in a WITH options clause in a SQL statement.

ODXSQL

>connect orders.env
>SET CHAR 32

or

>SELECT * FROM ORDERS WHERE STATUS='BACK' WITH CHAR=32

oaexecsql

oaexecsql (cursor, ";", status, "SET CHAR AUTO")

or

oaexecsql (cursor, "CHAR AUTO", status, "SELECT * FROM ORDERS WHERE STATUS='BACK'")

or

oaexecsql (cursor, ";", status, "SELECT * FROM ORDERS WHERE STATUS='BACK' WITH CHAR=AUTO")

JDBC

Statement stmt = connection.createStatement();
String sql = "SET CHAR AUTO";
stmt.execute(sql);

or

Statement stmt = connection.createStatement();
String sql = "SELECT * FROM ORDERS WHERE STATUS='BACK' WITH CHAR=AUTO";
ResultSet rs = stmt.executeQuery(sql);

Top