Database Manipulation APIs¶
Single Row Manipulation¶
cross_dbInsertRow¶
Intert row to Table
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 successfullyOther
: 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
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 successfullyOther
: 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
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 successfullyCROSS_E_NOTFOUND
: The row is not foundOther
: Decode with cross_errMsg
Description
pOutRow
= NULL can be used to check if row exists by Primary KeypOutRow
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 successfullyCROSS_E_NOTFOUND
: The row is not foundOther
: Decode with cross_errMsg
Description
pUpdFlds
can be cloumn list seperated by,
pUpdFlds
can be handle created by cross_fieldsCreatepUpdFlds
= NULL will update whole DB rowpUpdRow
can =pInRow
cross_dbDelRowByPK¶
Delete row by Primary Key
Parameters
Arg | Type | Descritpion |
---|---|---|
hTbl | in | Table Handle |
pInRow | in | Row buffer with Primary Key |
flags | [in] | Not used |
Returns
CROSS_OK
: Delete row successfullyCROSS_E_NOTFOUND
: No row is foundOther
: 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 successfullyCROSS_E_NOTFOUND
: No row is foundOther
: Decode with cross_errMsg
Description
pMatFlds
can be cloumn list seperated by,
, they areAND
together.fld
: equal to matchdbRow.fld
=pMatRow.fld
.fld!=
: unequal matchdbRow.fld
!=pMatRow.fld
.fld>
: greater than matchdbRow.fld
>pMatRow.fld
.fld>=
: greater than or equal to matchdbRow.fld
>=pMatRow.fld
.fld<
: less matchdbRow.fld
<pMatRow.fld
.fld<=
: leas than or equal to matchdbRow.fld
<pMatRow.fld
.
pMatFlds
can be handle created by cross_matchCreatepOutRow
= 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 successfullyOther
: Decode with cross_errMsg
Description
pMatFlds
can be cloumn list seperated by,
, they areAND
together. Refer cross_dbGetOneRowpMatFlds
can be handle created by cross_matchCreatepUpdFlds
can be cloumn list seperated by,
,pUpdFlds
can be handle created by cross_fieldsCreatepUpdFlds
=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 successfullyOther
: 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
>=0
: Rows countOther
: 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
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
>=0
: Rows countOther
: Decode with cross_errMsg
Description
pMatFlds
can be cloumn list seperated by,
, they areAND
together. Refer cross_dbGetOneRowpMatFlds
can be handle created by cross_matchCreate
cross_cursorGetNextRow¶
Get next row in cursor
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 successfullyCROSS_E_NOTFOUND
: No row is foundOther
: Decode with cross_errMsg
cross_cursorGetCount¶
Get cursor rows count
Parameters
Arg | Type | Descritpion |
---|---|---|
hCursor | in | Cursor Handle |
flags | [in] | Not used |
Returns
>=0
: Rows countOther
: Decode with cross_errMsg
cross_cursorClose¶
Close cursor
Parameters
Arg | Type | Descritpion |
---|---|---|
hCursor | in | Cursor Handle |
flags | [in] | Not used |
Returns
>=0
: Rows countOther
: Decode with cross_errMsg
Warning
Cursor handle can't be used after close.
Transaction¶
cross_dbTransBegin¶
Begin Transaction
Parameters
Arg | Type | Descritpion |
---|---|---|
hDb | in | DB Handle |
flags | [in] | Not used |
Returns
CROSS_OK
: Begin transaction successfullyOther
: Decode with cross_errMsg
Note
If there's onging transaction, it'll be commited first.
cross_dbTransCommit¶
Commit Transaction
Parameters
Arg | Type | Descritpion |
---|---|---|
hDb | in | DB Handle |
flags | [in] | Not used |
Returns
CROSS_OK
: Commit transaction successfullyOther
: Decode with cross_errMsg
cross_dbTransRollback¶
Rollback Transaction
Parameters
Arg | Type | Descritpion |
---|---|---|
hDb | in | DB Handle |
flags | [in] | Not used |
Returns
CROSS_OK
: Rollback transaction successfullyOther
: Decode with cross_errMsg