KI_START_BEG

Find the first row

Synopsis:
CALL KI_START_BEG handle, path, [SYM(row$)], [maxrows], [sql] TO status
status = 'ki_start_beg( handle, path, [SYM(row$)], [maxrows], [sql] )
ArgumentEnumerationPurpose
handleHandle
pathPath number
SYM(row$)Optional row buffer specifying the view
maxrowsMax number of rows required
sqlSQL Where Handle
statusKDB_ERROR_ENUMReturn status
>KI_START_BEG

KI_START_BEG

Sets the current sequential pointer to point before the first row of the rowset corresponding to the key path path. A subsequent KI_READ_NEXT will read the first row.

However, if path is negative, then the current pointer for the index ABS(path) is set to point after the last row on the key path. A subsequent KI_READ_NEXT for the same negative path will read the last row.

If the path is zero then the order is unspecified. It may follow an index path or it may be in the orders rows are laid out in the table. You can use a path of zero even if there are no actual indexes defined for the table.

The optional row buffer is no longer used and should be zero. The columns used in the SQL data base view will be taken from the columns in the row buffer passed to the first KI_READ_NEXT. The KI_START_BEG operation just logs the SQL that will be prepared and executed at the point of the first read.

The optional max_rows parameter can be used if you know you only want to read say the first row or, perhaps more commonly, the last row of a table. On an SQL database it gives the SQL optimizer more information about how it should perform the query and will avoid slow table scans. A missing or zero value implies that you don't know how many rows you will be reading. If you want to specify a max_rows value then pass zero as the SYM(row$) parameter.

The optional sql parameter can be used to pass SQL directly to the SQL database. The SQL passed here is inserted as part of any WHERE clause. To constuct the SQLHandle we need to use the #WHERE statement.

This function always succeeds if a table is open and the path corresponds to an actual index.

Compatibility

The optional row buffer argument was added and then deprecated in KCML 6.60 The maximum number of rows argument was introduced for KCML 6.60

The optional argument for SQL handle was introduced in KCML 7.07.

History
Introduced in KCML 3.00
See Also:
KI_BUILD, KI_COPY_TABLE, KI_CREATE, KI_CREATE_TMP, KI_DELETE, KI_DELETE_ROWS, KI_DELETE_WHERE, KI_END, KI_ERROR, KI_ERROR_TEXT, KI_FETCH, KI_GET_ERROR_TEXT, KI_GET_SERIAL, KI_GROW, KI_INFO, KI_INITIALISE, KI_LOCK_ALL, KI_LOCK_OWNER, KI_MOVE_ROWS, KI_MOVE_TABLE, KI_OPEN, KI_READ, KI_READ_ARRAY, KI_READ_HOLD, KI_READ_HOLD_NEXT, KI_READ_HOLD_PTR, KI_READ_NEXT, KI_READ_PTR, KI_READ_RANDOM, KI_READ_RAW, KI_REBUILD, KI_REWRITE, KI_SET_EXTENT, KI_SET_ROWS, KI_SET_SERIAL, KI_SET_WLOCK_COUNT, KI_SIZE_FILE, KI_START, KI_START_BETWEEN, KI_START_FIRST, KI_START_ON, KI_START_ROW, KI_START_ROW_BETWEEN, 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