Skip to content

Database Manipulation APIs

Single Row Manipulation


cross_dbInsertRow

Intert row to Table

cross_ret 
cross_dbInsertRow (cross_tbl_h hTbl, void *pRow, uint32_t flags);

Parameters

Arg Type Descritpion
hTbl in Table Handle
pRow in Row buffer to insert
pValFlds [in] Not used
flags [in] Not used

Returns

  • CROSS_OK: The row was inserted successfully
  • Other: Decode with cross_errMsg

Description

  • If table has Primary Key or unique index, it must be valid and unique.

cross_dbReplaceRow

Insert row to Table if not exist else replace row

cross_ret 
cross_dbReplaceRow (cross_tbl_h hTbl, void *pInRow, uint32_t flags);

Parameters

Arg Type Descritpion
hTbl in Table Handle
pRow in Row buffer to insert/update
pNullFlds in Not used
flags [in] Not used

Returns

  • CROSS_OK: The row was inserted/updated successfully
  • Other: Decode with cross_errMsg

Description

  • If table has Primary Key or unique index, it must be valid and unique.

cross_dbGetRowByPK

Get one row by Primary Key

cross_ret 
cross_dbGetRowByPK (cross_tbl_h hTbl, const void *pInRow, void *pOutRow, uint32_t flags);

Parameters

Arg Type Descritpion
hTbl in Table Handle
pInRow in Row buffer with Primary Key
pOutRow [out] Row buffer to return DB row
flags [in] Not used

Returns

  • CROSS_OK: Get row successfully
  • CROSS_E_NOTFOUND: The row is not found
  • Other: Decode with cross_errMsg

Description

  • pOutRow = NULL can be used to check if row exists by Primary Key
  • pOutRow can = pInRow

cross_dbUpdRowByPK

Update row by Primary Key

cross_ret 
cross_dbUpdRowByPK (cross_tbl_h hTbl, const void *pInRow, 
                    const void *pUpdFlds, void *pUpdRow, uint32_t flags);

Parameters

Arg Type Descritpion
hTbl in Table Handle
pInRow in Row buffer with Primary Key
pUpdFlds [in] Fields to update
pUpdRow in Row buffer to upate
flags [in] Not used

Returns

  • CROSS_OK: Update row successfully
  • CROSS_E_NOTFOUND: The row is not found
  • Other: Decode with cross_errMsg

Description

  • pUpdFlds can be cloumn list seperated by ,
  • pUpdFlds can be handle created by cross_fieldsCreate
  • pUpdFlds = NULL will update whole DB row
  • pUpdRow can = pInRow

cross_dbDelRowByPK

Delete row by Primary Key

cross_ret 
cross_dbDelRowByPK (cross_tbl_h hTbl, void *pInRow, uint32_t flags);

Parameters

Arg Type Descritpion
hTbl in Table Handle
pInRow in Row buffer with Primary Key
flags [in] Not used

Returns

  • CROSS_OK: Delete row successfully
  • CROSS_E_NOTFOUND: No row is found
  • Other: Decode with cross_errMsg

cross_dbGetOneRow

Get one row by match fields

cross_ret 
cross_dbGetOneRow (cross_tbl_h hTbl, const void *pMatFlds, const void *pMatRow, 
                    void *pOutRow, uint32_t flags);

Parameters

Arg Type Descritpion
hTbl in Table Handle
pMatFlds in Fields to match
pMatRow in Row buffer with match row
pOutRow [out] Row buffer to return DB row
flags [in] Not used

Returns

  • CROSS_OK: Get row successfully
  • CROSS_E_NOTFOUND: No row is found
  • Other: Decode with cross_errMsg

Description

  • pMatFlds can be cloumn list seperated by ,, they are AND together.
    • fld: equal to match dbRow.fld = pMatRow.fld.
    • fld!=: unequal match dbRow.fld != pMatRow.fld.
    • fld>: greater than match dbRow.fld > pMatRow.fld.
    • fld>=: greater than or equal to match dbRow.fld >= pMatRow.fld.
    • fld<: less match dbRow.fld < pMatRow.fld.
    • fld<=: leas than or equal to match dbRow.fld < pMatRow.fld.
  • pMatFlds can be handle created by cross_matchCreate
  • pOutRow = NULL can be used to check if row exists

Multiple Rows Manipulation


cross_dbUpdateRows

Update rows by match fields

cross_rowid 
cross_dbUpdateRows (cross_tbl_h hTbl, const void *pMatFlds, const void *pMatRow, 
                    const void *pUpdFlds, const void *pUpdRow, uint32_t flags);

Parameters

Arg Type Descritpion
hTbl in Table Handle
pMatFlds in Fields to match
pMatRow in Row buffer with match row
pUpdFlds [in] Upate specified fields
pUpdRow in Row buffer to update
flags [in] Not used

Returns

  • >=0: Rows count updated successfully
  • Other: Decode with cross_errMsg

Description

  • pMatFlds can be cloumn list seperated by ,, they are AND together. Refer cross_dbGetOneRow
  • pMatFlds can be handle created by cross_matchCreate
  • pUpdFlds can be cloumn list seperated by ,,
  • pUpdFlds can be handle created by cross_fieldsCreate
  • pUpdFlds = NULL updates whole row

cross_dbDeleteRows

Delete rows by match fields

cross_rowid 
cross_dbDeleteRows (cross_tbl_h hTbl, const void *pMatFlds, 
                    const void *pMatRow, uint32_t flags);

Parameters

Arg Type Descritpion
hTbl in Table Handle
pMatFlds in Fields to match
pMatRow in Row buffer with match row
flags [in] Not used

Returns

  • >=0: Rows count deleted successfully
  • Other: Decode with cross_errMsg

Description - pMatFlds can be cloumn list seperated by ,, they are AND together. Refer cross_dbGetOneRow - pMatFlds can be handle created by cross_matchCreate

cross_dbGetRowsCount

Get rows count by match fields

cross_rowid 
cross_dbGetRowsCount (cross_tbl_h hTbl, const void *pMatFlds, 
                        const void *pMatRow, uint32_t flags);

Parameters

Arg Type Descritpion
hTbl in Table Handle
pMatFlds in Fields to match
pMatRow in Row buffer with match row
flags [in] Not used

Returns

Description - pMatFlds can be cloumn list seperated by ,, they are AND together. Refer cross_dbGetOneRow - pMatFlds can be handle created by cross_matchCreate

Cursor

cross_dbQueryRows

Query rows into cursor

cross_rowid 
cross_dbQueryRows (cross_tbl_h hTbl, cross_cursor_h *phCursor, const void *pMatFlds, 
                    const void *pMatRow, uint32_t flags);

Parameters

Arg Type Descritpion
hTbl in Table Handle
phCursor io|out Return Cursor handle or
pMatFlds in Fields to match
pMatRow in Row buffer with match row
flags [in] CROSS_REUSE means phCursor points to a valid cursor handle and it'll be reused

Returns

Description

cross_cursorGetNextRow

Get next row in cursor

cross_ret 
cross_cursorGetNextRow (cross_cursor_h hCursor, void *pOutRow, uint32_t flags);

Parameters

Arg Type Descritpion
hCursor in Cursor Handle
pOutRow [out] Row buffer to return DB row
flags [in] Not used

Returns

  • CROSS_OK: Get next row successfully
  • CROSS_E_NOTFOUND: No row is found
  • Other: Decode with cross_errMsg

cross_cursorGetCount

Get cursor rows count

cross_rowid 
cross_cursorGetCount (cross_cursor_h hCursor, uint32_t flags);

Parameters

Arg Type Descritpion
hCursor in Cursor Handle
flags [in] Not used

Returns

cross_cursorClose

Close cursor

cross_ret 
cross_cursorClose (cross_cursor_h hCursor, uint32_t flags);

Parameters

Arg Type Descritpion
hCursor in Cursor Handle
flags [in] Not used

Returns

Warning

Cursor handle can't be used after close.

Transaction


cross_dbTransBegin

Begin Transaction

cross_ret cross_dbTransBegin (cross_db_h hDb, uint32_t flags);

Parameters

Arg Type Descritpion
hDb in DB Handle
flags [in] Not used

Returns

  • CROSS_OK: Begin transaction successfully
  • Other: Decode with cross_errMsg

Note

If there's onging transaction, it'll be commited first.

cross_dbTransCommit

Commit Transaction

cross_ret 
cross_dbTransCommit (cross_db_h hDb, uint32_t flags);

Parameters

Arg Type Descritpion
hDb in DB Handle
flags [in] Not used

Returns

  • CROSS_OK: Commit transaction successfully
  • Other: Decode with cross_errMsg

cross_dbTransRollback

Rollback Transaction

cross_ret 
cross_dbTransRollback (cross_db_h hDb, uint32_t flags);

Parameters

Arg Type Descritpion
hDb in DB Handle
flags [in] Not used

Returns

  • CROSS_OK: Rollback transaction successfully
  • Other: Decode with cross_errMsg

Comments