Contents IndexData type conversion functions Miscellaneous functions

User's Guide
   Part VI. SQL Anywhere Reference
     Chapter 42. Watcom-SQL Functions
      System functions

Purpose

System functions return system information.

Syntax

     System function:
          connection_property ( { integer-expr | string-expr }
                          ... [ , integer-expr ] )
          | datalength ( expression )
          | db_id ( [ string-expr ] )
          | db_name ( [ integer-expr ] )
          | db_property ( { integer-expr | string-expr }
          ... [,{ integer-expr | string-expr }] )
          | next_connection ( { NULL | string-expr } )
          | next_database ( { NULL | string-expr } )
          | property ( { integer-expr | string-expr } )
          | property_name ( integer-expr )
          | property_number ( string-expr )
          | property_description ( { integer-expr | string-expr } )

See also

Description

Databases currently running on a server or engine are identified by a database name and a database id number. The db_id and db_name functions provide information on these values.

A set of system functions provides information about properties of a currently running database, or of a connection, on the database engine. These system functions take the database name or ID, or the connection name, as an optional argument to identify the database or connection for which the property is requested.

The available properties and their uses are described following the listing of the functions.

connection_property ( { property-id | property-name } [, connection-id ] ) Returns the value of the given property as a string. The current connection is used if the second argument is omitted.

datalength ( expression ) Returns the length of the expression in bytes. The expression is usually a column name. If the expression is a string constant, it must be enclosed in quotes. The following query displays the longest string in the company_name column of the customer table:

     SELECT MAX( DATALENGTH( company_name ) )
     FROM customer

db_id ( [database-name] ) Returns the database ID number. The supplied database_name must be a string expression; if it is a constant expression, it must be enclosed in quotes. If no database_name is supplied, the ID number of the current database is returned.

db_name ( [database-id] ) Returns the database name. The supplied database_idmust be a numeric expression. If no database_id is supplied, the name of the current database is returned.

db_property ( { property-id | property-name } [, { database-id | database-name } ] ) Returns the value of the given property as a string. The current database is used if the second argument is omitted.

next_connection ( { NULL | connection-id } ) Returns the next connection number, or the first connection if parm is NULL.

next_database ( { NULL | database-id } ) Returns the next database number, or the first connection if parm is NULL.

property ( { property-number | property-name } ) Returns the value of the specified property as a string.

property_name ( property-number ) Returns the name of the property with the supplied property-number.

property_number ( property-name ) Returns the number of the property with the supplied property-name.

property_description ( { property-number | property-name } ) Returns a description of the property with the supplied property-name or property-number. The statistics and properties available are those in the following list. The list includes the name of each property, and a brief description. While each property does have a number as well as a name, the number is subject to change between releases of SQL Anywhere, and should not be used as a reliable identifier for a given property.

Top of page


Connection properties

The following table lists properties available for each connection.

Examples

To retrieve the value of a connection property:

To retrieve the values of all connection properties:

Descriptions

Property Description
Async2Read The number of rereads. A reread occurs when a read request for a page is received by the database IO subsystem while an asynchronous read IO operation has been posted to the operating system but has not completed.
AsyncRead The number of pages that have been read asynchronously from disk.
AsyncWrite The number of pages that have been written asynchronously to disk.
BlockedOn If the current connection is not blocked this is zero. If it is blocked, the connection number on which the connection is blocked due to a locking conflict.
CacheRead The number of database pages that have been looked up in the cache.
CacheReadIndInt The number of index internal-node pages that have been read from the cache.
CacheReadIndLeaf The number of index leaf pages that have been read from the cache.
CacheReadTable The number of table pages that have been read from the cache.
CacheWrite The number of pages in the cache that have been modified.
Commit The number of Commit requests that have been handled.
CommLink The communication link for the connection. This is one of the network protocols supported by SQL Anywhere, or is "local" for a connection without a SQL Anywhere Client.
CurrTaskSwitch The number of current request context switches.
Cursors The number of declared cursors that are currently being maintained by the engine.
CursorOpen Open cursors is the number of open cursors that are currently being maintained by the engine.
DBNumber The id number of the database.
DiskRead The number of pages that have been read from file.
DiskReadIndInt The number of index internal-node pages that have been read from disk.
DiskReadIndLeaf The number of index leaf pages that have been read from disk.
DiskReadTable The number of table pages that have been read from disk.
DiskSyncRead The number of pages that have been read synchronously from disk..
DiskSyncWrite The number of pages that have been written synchronously to disk. It is the sum of all the other "Disk SyncWrites" counters.
DiskWaitRead The number of times the engine has waited synchronously for the completion of a read IO operation which was originally issued as an asynchronous read. Waitreads often occur due to cache misses on systems that support asynchronous IO.
DiskWaitWrite The number of times engine has waited synchronously for the completion of a write IO operation which was originally issued as an asynchronous write.
DiskWrite The number of modified pages that have been written to disk.
FullCompare The number of comparisons beyond the hash value in an index that have been performed.
HintUsed The number of page-read operations that have been satisfied immediately from cache thanks to a earlier read hint.
IndAdd The number of entries that have been added to indexes.
IndLookup The number of entries that have been looked up in indexes.
LastIdle The number of ticks between requests.
LastReqTime The time at which the last request for the specified connection started.
LockTablePages The number of pages used for the lock table.
LogFreeCommit The number of Redo Free Commits. A "Redo Free Commit" occurs when a commit of the transaction log is requested but the log has already been written (so the commit was done for "free").
LogRewrite The number of pages that were previously written to the transaction log (but were not full) that have been written to the transaction log again (but with more data added).
LogWrite The number of pages that have been written to the transaction log.
Name The database name.
NodeAddress The node for the client in a client/server connection.
Number The ID number of the connection.
Port An application-specific number for each client machine, identifying the connection port.
PrepStmt The number of prepared statements that are currently being maintained by the engine.
ProcessTime The time since the start of the connection.
ReadHint The number of read hints. A read hint is an asynchronous read operation for a page that the database engine is likely to need soon.
ReqType A string for the type of the last request.
Rlbk The number of Rollback requests that have been handled.
RollbackLogPages The number of pages in the rollback log
SyncWriteChkpt The number of pages that have been written synchronously to disk for a checkpoint.
SyncWriteExtend The number of pages that have been written synchronously to disk while extending a database file.
SyncWriteFreeCurr The number of pages that have been written synchronously to disk to free a page that cannot remain in the in-memory free list.
SyncWriteFreePush The number of pages that have been written synchronously to disk to free a page that can remain in the in-memory free list.
SyncWriteLog The number of pages that have been written synchronously to the transaction log.
SyncWriteRlbk The number of pages that have been written synchronously to the rollback log.
SyncWriteUnkn The number of pages that have been written synchronously to disk for a reason not covered by other "Disk SyncWrites" counters.
TaskSwitch The number of times the current engine thread has been changed.
TaskSwitchCheck The number of times the current engine thread has volunteered to give up the CPU to another engine thread.
UncommitOp The number of uncommitted operations for the connection.
Userid The user ID for the connection.
VoluntaryBlock The number of engine threads that have voluntarily blocked on pending disk IO.
WaitReadCmp The number of read requests associated with a full comparison (a comparison beyond the hash value in an index) that must be satisfied by a synchronous read operation.
WaitReadOpt The number of read requests posted by the optimizer that must be satisfied by a synchronous read operation.
WaitReadSys The number of read requests posted from the system connection that must be satisfied by a synchronous read operation. The system connection is a special connection used as the context before a connection is made and for operations performed outside of any client connection.
WaitReadTemp The number of read requests for a temporary table that must be satisfied by a synchronous read operation.
WaitReadUnkn The number of read requests from other sources that must be satisfied by a synchronous read operation.

Top of page


Properties available for the engine

The following table lists properties that apply across the engine as a whole.

Examples

To retrieve the value of an engine property:

To retrieve the values of all engine properties:

Descriptions

Property Description
ActiveReq The number of engine threads that are currently handling a request.
Async2Read The number of rereads. A reread occurs when a read request for a page is received by the database IO subsystem while an asynchronous read IO operation has been posted to the operating system but has not completed.
AsyncRead The number of pages that have been read asynchronously from disk.
AsyncWrite The number of pages that have been written asynchronously to disk.
CacheHits The number of database page lookups satisfied by finding the page in the cache.
CacheRead The number of database pages that have been looked up in the cache.
CacheReadIndInt The number of index internal-node pages that have been read from the cache.
CacheReadIndLeaf The number of index leaf pages that have been read from the cache.
CacheReadTable The number of table pages that have been read from the cache.
CacheWrite The number of pages in the cache that have been modified.
Chkpt The number of checkpoints that have been performed.
ChkptFlush The number of ranges of adjacent pages written out during a checkpoint.
ChkptPage The number of transaction log checkpoints.
CommitFile The number of times the engine has forced a flush of the disk cache. On NT and NetWare platforms, the disk cache does not need to be when unbuffered (direct) IO is used.
CompanyName The name of the company owning this software (Sybase, Inc.).
ContReq The number of "CONTINUE" requests issued to the engine.
CurrIO The current number of file IOs issued by the engine which have not yet completed.
CurrRead The current number of file reads issued by the engine which have not yet completed.
CurrWrite The current number of file writes issued by the engine which have not yet completed.
DiskRead The number of pages that have been read from file.
DiskReadIndInt The number of index internal-node pages that have been read from disk.
DiskReadIndLeaf The number of index leaf pages that have been read from disk.
DiskReadTable The number of table pages that have been read from disk.
DiskSyncRead The number of pages that have been read synchronously from disk.
DiskSyncWrite The number of pages that have been written synchronously to disk. It is the sum of all the other "Disk SyncWrites" counters.
DiskWaitRead The number of times the engine has waited synchronously for the completion of a read IO operation which was originally issued as an asynchronous read. Waitreads often occur due to cache misses on systems that support asynchronous IO.
DiskWaitWrite The number of times engine has waited synchronously for the completion of a write IO operation which was originally issued as an asynchronous write.
DiskWrite The number of modified pages that have been written to disk.
ExtendDBWrite The number of pages by which the database file has been extended.
ExtendTempWrite The number of pages by which temporary files have been extended.
FreeWriteCurr The number of pages freed of those that cannot remain in the in-memory free list.
FreeWritePush The number of pages freed of those that can remain in the in-memory free list.
FullCompare The number of comparisons beyond the hash value in an index that have been performed.
HintUsed The number of page-read operations that have been satisfied immediately from cache thanks to a earlier read hint.
IdleCheck The number of times the engine's idle thread has become active to do idle writes, idle checkpoints, and so on.
IdleChkpt The number of checkpoints completed by the engine's idle thread. An idle checkpoint occurs whenever the idle thread writes out the last dirty page in the cache.
IdleChkTime The number of 100'ths of a second spent checkpointing during idle I/O.
IdleWrite The number of disk writes that have been issued by the engine's idle thread.
IndAdd The number of entries that have been added to indexes.
IndLookup The number of entries that have been looked up in indexes.
LegalCopyright The Copyright string for the software.
LegalTrademarks Trademark information for the software.
LockTablePages The number of pages used to store lock information
LogFreeCommit The number of Redo Free Commits. A "Redo Free Commit" occurs when a commit of the transaction log is requested but the log has already been written (so the commit was done for "free").
LogRewrite The number of pages that were previously written to the transaction log (but were not full) that have been written to the transaction log again (but with more data added).
LogWrite The number of pages that have been written to the transaction log.
MainHeapPages The number of pages used for global engine data structures.
MapPages The number of map pages used for accessing the lock table, frequency table, and table layout.
MaxIO The maximum value that "Current IO" has reached.
MaxRead The maximum value that "Current Reads" has reached.
MaxWrite The maximum value that "Current Writes" has reached.
Name The name of the engine or server.
PageRelocations The number of relocatable heap pages read from the temporary file.
PendingReq The number of new requests detected by the engine.
Platform The operating system on which the software is running.
ProcedurePages The number of relocatable heap pages used for procedures.
ProductName The name of the software.
ProductVersion The version of the software being run.
ReadHint The number of read hints. A read hint is an asynchronous read operation for a page that the database engine is likely to need soon.
RelocatableHeapPages The number of pages used for relocatable heaps (cursors, statements, procedures, triggers, views, etc.).
Req The number of times the engine has been entered to allow it to handle a new request or continue processing an existing request.
RollbackLogPages The number of pages in the rollback log.
SyncWriteChkpt The number of pages that have been written synchronously to disk for a checkpoint.
SyncWriteExtend The number of pages that have been written synchronously to disk while extending a database file.
SyncWriteFreeCurr The number of pages that have been written synchronously to disk to free a page that cannot remain in the in-memory free list.
SyncWriteFreePush The number of pages that have been written synchronously to disk to free a page that can remain in the in-memory free list.
SyncWriteLog The number of pages that have been written synchronously to the transaction log.
SyncWriteRlbk The number of pages that have been written synchronously to the rollback log.
SyncWriteUnkn The number of pages that have been written synchronously to disk for a reason not covered by other "Disk SyncWrites" counters.
TriggerPages The number of relocatable heap pages used for triggers.
UnschReq The number of requests that are currently queued up waiting for an available engine thread.
ViewPages The number of relocatable heap pages used for views.
VoluntaryBlock The number of engine threads that have voluntarily blocked on pending disk IO.
WaitReadCmp The number of read requests associated with a full comparison (a comparison beyond the hash value in an index) that must be satisfied by a synchronous read operation.
WaitReadOpt The number of read requests posted by the optimizer that must be satisfied by a synchronous read operation.
WaitReadSys The number of read requests posted from the system connection that must be satisfied by a synchronous read operation. The system connection is a special connection used as the context before a connection is made and for operations performed outside of any client connection.
WaitReadTemp The number of read requests for a temporary table that must be satisfied by a synchronous read operation.
WaitReadUnkn The number of read requests from other sources that must be satisfied by a synchronous read operation.

Top of page


Properties available for each database

The following table lists properties available for each database on the server.

Examples

To retrieve the value of a database property:

To retrieve the values of all database properties:

Descriptions

Property Description
Alias The database name.
ConnCount The number of connections to the database.
File The file name of the database root file, including path.
FileVersion The version of the database file.
LogName The file name of the transaction log, including path.
Name The database name, or alias.
PageSize The page size of the database, in bytes.

Top of page


Contents IndexData type conversion functions Miscellaneous functions