Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Reference » SQL Functions » Alphabetical list of functions

NEWID function [Miscellaneous] Next Page

NEXT_CONNECTION function [System]


Returns an identifying number for the next connection.

Syntax

NEXT_CONNECTION( [ connection-id ] [, database-id ] )

Parameters

connection-id    An integer, usually returned from a previous call to NEXT_CONNECTION. If connection-id is NULL, NEXT_CONNECTION returns the most recent connection ID.

database-id    An integer representing one of the databases on the current server. If you supply no database-id, the current database is used. If you supply NULL, then NEXT_CONNECTION returns the next connection regardless of database.

Remarks

NEXT_CONNECTION can be used to enumerate the connections to a database. Connection IDs are generally created in monotonically increasing order. This function returns the next connection ID in reverse order.

To get the connection ID value for the most recent connection, enter NULL as the connection-id. To get the subsequent connection, enter the previous return value. The function returns NULL when there are no more connections in the order.

NEXT_CONNECTION is useful if you want to disconnect all the connections created before a specific time. However, because NEXT_CONNECTION returns the connection IDS in reverse order, connections made after the function is started are not returned. If you want to ensure that all connections are disconnected, prevent new connections from being created before you run NEXT_CONNECTION.

Standards and compatibility
Example

The following statement returns an identifier for the first connection on the current database. The identifier is an integer value like 10.

SELECT NEXT_CONNECTION( NULL );

The following statement returns a value like 5.

SELECT NEXT_CONNECTION( 10 );

The following call returns the next connection ID in reverse order from the specified connection-id on the current database.

SELECT NEXT_CONNECTION( connection-id );

The following call returns the next connection ID in reverse order from the specified connection-id (regardless of database).

SELECT NEXT_CONNECTION( connection-id, NULL );

The following call returns the next connection ID in reverse order from the specified connection-id on the specified database.

SELECT NEXT_CONNECTION( connection-id, database-id );

The following call returns the first (earliest) connection (regardless of database).

SELECT NEXT_CONNECTION( NULL, NULL );

The following call returns the first (earliest) connection on the specified database.

SELECT NEXT_CONNECTION( NULL, database-id );