NAME
sp_set - insert or replace operation
SYNOPSIS
#include <sophia.h>
int sp_set(void *object, void *document);
DESCRIPTION
sp_set(database, document): do a single-statement transaction.
sp_set(transaction, document): do a key update as a part of multi-statement transaction.
As a part of a transactional statement a key-value document must be prepared using sp_document() method. First argument of sp_document() method must be a database object.
Object must be prepared by setting key and value fields, where value is optional. It is important that while setting key and value fields, only pointers are copied. Real data copies only during first operation.
For additional information take a look at sp_document(), sp_begin() and Transactions.
EXAMPLE
char key[] = "key";
void *o = sp_document(db);
sp_setstring(o, "key", key, sizeof(key));
sp_setstring(o, "value", "hello world", 0);
sp_set(db, o);
RETURN VALUE
On success, sp_set() returns 0. On error, it returns -1.
Database object commit: (1) rollback or (2) lock.
SEE ALSO