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

SQL Anywhere 11.0.1 » SQL Anywhere Server - SQL Reference » Using SQL » SQL functions » SQL functions (E-O)

 

NEXT_DATABASE function [System]

Returns an identifying number for a database.

Syntax
NEXT_DATABASE( { NULL | database-id } )
Parameters
  • database-id   An integer that specifies the ID number of the database.

Returns

INT

Remarks

The NEXT_DATABASE function is used to enumerate the databases running on a database server. To get the first database pass NULL; to get each subsequent database, pass the previous return value. The function returns NULL when there are no more databases. The database ID numbers are not returned in a particular order, but you can tell the order in which connections were made to the server using the database ID. The first database that connects to the server is assigned the value 0, and for subsequent connections to the server, the database IDs are incremented by a value of 1.

Standards and compatibility
  • SQL/2003   Transact-SQL extension.

Example

The following statement returns the value 0, the first database value.

SELECT NEXT_DATABASE( NULL );

The following statement returns NULL, indicating that there are no more databases on the server.

SELECT NEXT_DATABASE( 0 );