Home

Getting Started

Utilities

Indexing

Omnidex

Development

Tutorials

Quick Links

 

SQL Reference

ON CURSOR / ON INSTANCE

Syntax

Example

 

SQL Reference

SELECT Statement

Joins

Nested Queries

Set Operations

ON CURSOR | INSTANCE

WITH Options

Commands

Functions

Nearly every command in the Omnidex SQL library supports the ON CURSOR n or ON INSTANCE n clause to allow Omnidex applications to make use of multiple cursors. This clause is appended to the end of an SQL statement, but before the optional WITH options statement.

In ODXSQL, use the CURSORDISPLAY ON set option to automatically display the current cursor and instance numbers.

>SET CURSORDISPLAY ON

>connect /users/garment.env
Connected to /users/garment.env on instance 2, cursor 2

>SELECT COMPANY, CONTACT, PHONE FROM CUSTOMERS WHERE STATE='CO' ON CURSOR 2

The ON CURSOR n clause is optional. If it is not specified, the SQL statement will be executed on the current cursor defined in the cursor parameter of the status array.

The ON INSTANCE n clause can only be used by statements that do not require a cursor to be open. This includes statements like INSERT, INSERTINDEX, and many more. See the individual statement definitions for information on whether the statement uses an instance or a cursor. If omitted, the SQL statement will be executed on the instance owning the cursor passed in the cursor parameter of oaexecsql or in the instance member of the status array.

Each individual JDBC Statement object and ODBC CLI HSTMT objects are created on their own cursors. Likewise, each Connection object in both types of applications are created on their own instances. Therefore, the use of the ON CURSOR and ON INSTANCE clauses is unnecessary. To switch between multiple cursors or instances, simply reference the appropriate object.

 

Syntax

statement [ON [CURSOR] n | [INSTANCE] n] [WITH options]

statement

Required. Any valid SQL statement supported by Omnidex.

ON

Required if specifying the cursor or instance number. Omit if using the default current cursor or instance.

[CURSOR | INSTANCE]

Optional. The CURSOR and INSTANCE keywords are optional.

n

Required if specifying the cursor or instance number. Omit if using the default current cursor or instance. This is the cursor or instance number that the current command will be executed on. Cursors and instances are numbered automatically as they are created. In OdxSQL, use the CURSORDISPLAY ON set option to automatically display the current cursor and instance numbers.

[WITH options]

Optional. A comma separated list of options to use for the current statement.

 

ODXSQL Example

>SET CURSORDISPLAY ON

>connect /users/garment.env
Connected to /users/garment.env on instance 1, cursor 1

>connect / users/orders.env
Connected to /users/orders.env on instance 2, cursor 2

SELECT COMPANY, CONTACT, PHONE FROM CUSTOMERS WHERE STATE='CO' ON CURSOR 2
...

INSERT INTO CUSTOMERS (COMPANY, CONTACT) VALUES ('New Wave', 'Mr. Smith') ON CURSOR 1
...

 

Top