KI_MOVE_ROWS

Archive rows from one table to another in a database

Synopsis:
CALL KI_MOVE_ROWS h1, h2, SYM(rowid$()), [nRows] TO status
status = 'ki_move_rows( h1, h2, SYM(rowid$()), [nRows] )
ArgumentEnumerationPurpose
h1Source handle
h2Destination handle
SYM(rowid$())Location of rows in source table
nRowsOptional, rows to archive, zero means use array size
statusKDB_ERROR_ENUMReturn status
>KI_MOVE_ROWS

KI_MOVE_ROWS

This can be used to archive a batch of rows from one table to another with an identical or a subset schema. The column names of the archive table must have exactly the same base names, excluding the optional prefix, as their equivalents in the original table, though not all columns need appear in the archive and they don't have to be in the same order.

The rowid$() array contains the rowids of the rows to be moved. It should be a single dimensioned array with each element an instance of the _KDB_ROWID record. The array can be sized to the number of rowids available but, if larger, the actual number of rowids in the array can be specified with the optional nRows parameter. A zero value for this parameter implies that all the array elements are significant.

This function can be enclosed in a WHILE TRANS transaction but if used outside of a transaction it will execute in an internal transaction guaranteeing an atomic result. Because it uses a temporary table and Oracle DDL will commit any transaction, the statement should not be used in a WHILE TRANS for Oracle.

If a rowid is not found in a KDB7 table then a _KE_NOTFOUND error will be reported and the move will be abandoned at that point. On an SQL database like Oracle the error will be silently ignored.

If one table is word indexed then the other table must have either no index or an identical index. If there are no word indexes on the tables then the operation can be done entirely on the database server but word indexing requires the indexed columns of the rows to be processed by the application server incurring a greater performance overhead.

Compatibility

Not available for KDB6 or earlier.

History
Introduced in KCML 6.69
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_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_BEG, 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