KI_INFO

Retrieve details of a table or connection

Synopsis:
CALL KI_INFO handle, path, SYM(buf$), [eOpt] TO status
status = 'ki_info( handle, path, SYM(buf$), [eOpt] )
ArgumentEnumerationPurpose
handleHandle
pathPath number
SYM(buf$)Symbol of a buffer to hold data
eOptKDB_INFO_OPTS_ENUMRow count and serial number options
statusKDB_ERROR_ENUMReturn status
>KI_INFO

KI_INFO

This routine returns information about the table in a structure whose symbol index is passed in sym. The information returned depends on the value of the handle and path parameters passed in the call. The structure to be returned should be declared as a DEFRECORD using the appropriate built in constants and indexed using the built in fields defined therein.

Table information

If the variable path is zero in the call, then information about the table open on the handle is supplied. Getting the row count or the current autoserial value for Oracle tables can be slow, so the optional eOpts enumerated constant argument makes these operations optional.

To discover if the table is empty _KDB_INFO_TEST_FOR_ROWS tries to read a single row, returning the number of rows read, 0 or 1. For Oracle this is quicker than getting the exact row count. For compatibility with Oracle, KDB also honours this optional argument.

The options for are controlled by a KCML enumerated constants documented here. The row count options are an enumeration which can be added to the autoserial option.

For example:

     DIM key_info$_KDB_INFO_HAND
     status = 'KI_INFO(handle, 0, SYM(key_info$), _KDB_INFO_ROW_COUNT)

For KDB type 7 and all SQL database tables key_info$ must be an instance of the KDB_INFO_HAND record.

For KDB type 6 and earlier tables the following subset of fields are available in a 224 byte string key_info$:

Offsetlengthpurpose
11 'K' for native KCML database table, 'Q' for a layered SQL database table, e.g. Oracle
21 version number (in ASCII)
31 LSB of partition no. of exclusive owner (in binary)
41 number of indices (in binary)
52 row length in bytes
141 MSB of partition no. of exclusive owner (in binary)
222 maximum index blocks (obsolete, see offset 85)
242 index blocks in use (obsolete, see offset 81)
423 maximum rows (obsolete, see offset 77)
453 count of rows in table (obsolete, see offset 73)
543 next available row number (obsolete, see offset 89)
651 KCML stream number (obsolete, KCML4 and earlier only, no longer supported)
661 Last major error code for the handle
671 Last minor error code for the handle
681 Last Operating System error code for the handle
691 Handle status as a bit field containing the following,
0x00 unused
0x01 nothing open now
0x02 open/connected
0x04 SQL prepared
0x08 result set exists
0x10 flat file open
0x20 BU file open
734 count of rows in table
774 max allowed rows in table
814 count of index blocks in use
854 max allowed index blocks
894 data high water mark
931 Mode that the table was opened with (KCML 6.00 or later), eg "R"ead, "W"rite etc.
941 number of index extents in a KISAM type 6 table
951 number of data extents in a KISAM type 6 table
12996 table name

Connection information

If the handle supplied is negative then information is returned about the connection open on that handle, e.g.

     DIM key_info$_KDB_INFO_CONN
     status = 'KI_INFO(-hConnect, 0, SYM(key_info$))

Here key_info$ must be an instance of a KDB_INFO_CONN record.

Index information

In the example below, if path is non-zero, then information about index key path is returned in the variable ki_info$, e.g.:

     DIM key_info$_KDB_INFO_IDX
     status = 'KI_INFO(handle, path, SYM(key_info$))

For KDB type 7 and all SQL databases key_info$ must be an instance of a KDB_INFO_IDX record. It contains an array of KDB_INFO_COL records detailing the columns within the key.

For KDB type 6 and earlier tables key_info$ should be a string of at least 72 bytes which will be returned in this format:

Offsetlengthpurpose
12reserved
31total key length
41duplicates allowed (Y/N)
53reserved
864index column descriptor array

The type 6 key segment array must be at least 32 bytes long, 8 * 4 bytes. The key component structure is the same array specified in KI_CREATE. The first two bytes of each element define the byte offset of the start of that column. A zero start indicates the end of the components. The third byte defines the length of that component (total key length must not exceed 128). The fourth byte is currently reserved and must be zero.

Offsetlengthpurpose
12start of column, counted from 1
31length of column, binary
41flag byte, HEX(00) for now

Word search index information

If path is negative, and the open table is a KDB type 7 or SQL database table, then word search index information is returned in an instance of a KDB_INFO_WSX record.

The index column descriptor array holds information for the fields from which words are to be extracted and is an 8 element array, with each element an instance of the KDB_INFO_WS_COL record.

History
Introduced in KCML 3.00
See Also:
KI_ALLOC_CONNECT, KI_CLEAR, KI_CLOSE, KI_CLOSE_TABLE, KI_CONNECT, KI_CONNECT_GET_ATTR, KI_CONNECT_GET_ATTR_STR, KI_CONNECT_SET_ATTR, KI_CONNECT_SET_ATTR_STR, KI_COPY_TABLE, KI_CREATE, KI_CREATE_TMP, KI_DB_NAME, KI_DELETE_ROWS, KI_DISCONNECT, KI_DROP_TABLE, KI_ERROR, KI_ERROR_TEXT, KI_EXTEND, KI_FREE_CONNECT, KI_GET_ERROR_TEXT, KI_GET_HANDLE, KI_GET_LANGUAGES, KI_GET_SERIAL, KI_GROW, KI_HANDLE_GET_ATTR_POOL, KI_INITIALISE, KI_LOCK_ALL, KI_LOCK_OWNER, KI_MOVE_ROWS, KI_MOVE_TABLE, KI_OPEN, KI_PREFETCH_ROWS, KI_READ, KI_READ_HOLD, KI_READ_HOLD_NEXT, KI_READ_HOLD_PTR, KI_READ_NEXT, KI_READ_PTR, KI_READ_RAW, KI_REBUILD, KI_REDIR_CONNECT, KI_RESET_CACHEID, KI_REWRITE, KI_SET_DATESTAMP, KI_SET_EXTENT, KI_SET_LANGUAGE, KI_SET_LANGUAGES, KI_SET_ROWS, KI_SET_SERIAL, KI_SET_TIMESTAMP, KI_SET_USERSTAMP, KI_SET_WLOCK_COUNT, KI_SIZE_FILE, KI_START, KI_START_BEG, KI_UNLOCK, KI_UNLOCK_FILE, KI_VERIFY, KI_WMODE_BITMAP, KI_WRITE, KI_WRITE_PTR, KI_WRITE_RAW, KI_WS_CREATE, KI_WS_DELETE, KI_WS_OPEN, KI_WS_READ, KI_WS_REWRITE, KI_WS_WRITE
KCML database status codes