head 1.2; access; symbols RPM_4_2_1:1.1.1.5 RPM_4_2:1.1.1.5 RPM_4_1_1:1.1.1.5 RPM_4_1:1.1.1.4 RPM_4_0_5:1.1.1.3 RPM_4_0_4:1.1.1.2 RPM_4_0_3:1.1.1.1 RPM:1.1.1; locks; strict; comment @# @; 1.2 date 2008.01.02.09.54.38; author rse; state dead; branches; next 1.1; commitid z4cpSiAhOCXk5PLs; 1.1 date 2001.07.23.20.45.37; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2001.07.23.20.45.37; author rse; state Exp; branches; next 1.1.1.2; 1.1.1.2 date 2002.01.08.00.30.11; author rse; state Exp; branches; next 1.1.1.3; 1.1.1.3 date 2003.01.18.13.49.01; author rse; state Exp; branches; next 1.1.1.4; 1.1.1.4 date 2001.07.23.20.09.17; author rse; state Exp; branches; next 1.1.1.5; 1.1.1.5 date 2003.01.18.14.04.59; author rse; state Exp; branches; next ; desc @@ 1.2 log @remove the ancient RPM 4.2.1 source tree copy @ text @
|
![]() ![]() ![]() |
The DBcursor->c_put function is the standard interface for storing records into the database with a cursor. In general, DBcursor->c_put takes a key and inserts the associated data into the database, at a location controlled by a specified flag.
There are several flags that you can set to customize storage:
In all cases, the cursor is repositioned by a DBcursor->c_put operation to point to the newly inserted key/data pair in the database.
The following is a code example showing a cursor storing two data items in a database that supports duplicate data items:
int store(dbp) DB *dbp; { DBC *dbcp; DBT key, data; int ret;/* * The DB handle for a Btree database supporting duplicate data * items is the argument; acquire a cursor for the database. */ if ((ret = dbp->cursor(dbp, NULL, &dbcp, 0)) != 0) { dbp->err(dbp, ret, "DB->cursor"); goto err; }
/* Initialize the key. */ memset(&key, 0, sizeof(key)); key.data = "new key"; key.size = strlen(key.data) + 1;
/* Initialize the data to be the first of two duplicate records. */ memset(&data, 0, sizeof(data)); data.data = "new key's data: entry #1"; data.size = strlen(data.data) + 1;
/* Store the first of the two duplicate records. */ if ((ret = dbcp->c_put(dbcp, &key, &data, DB_KEYFIRST)) != 0) dbp->err(dbp, ret, "DB->cursor");
/* Initialize the data to be the second of two duplicate records. */ data.data = "new key's data: entry #2"; data.size = strlen(data.data) + 1;
/* * Store the second of the two duplicate records. No duplicate * record sort function has been specified, so we explicitly * store the record as the last of the duplicate set. */ if ((ret = dbcp->c_put(dbcp, &key, &data, DB_KEYLAST)) != 0) dbp->err(dbp, ret, "DB->cursor");
err: if ((ret = dbcp->c_close(dbcp)) != 0) dbp->err(dbp, ret, "DBcursor->close");
return (0); }
![]() ![]() ![]() |
Copyright Sleepycat Software @ 1.1 log @Initial revision @ text @d1 1 a1 1 @ 1.1.1.1 log @Import: RPM 4.0.3 @ text @@ 1.1.1.2 log @Import: RPM 4.0.4 @ text @d1 1 a1 1 @ 1.1.1.3 log @Import: RPM 4.0.5 @ text @d1 2 a2 2 a3 1 d18 1 a18 1
The DBcursor->c_put method is the standard interface for storing records into d28 1 a28 1
The DBcursor->c_put function is the standard interface for storing records into d29 1 a29 1
The DBcursor->c_put method is the standard interface for storing records into d28 1 a28 1