Transactions Example

Create a character map and a table, and commit or roll them back together.

 

lpar_t   tran ;   /* the transaction id parameters. */
dvkerr_t err ; /* return status of Devkit function calls */
/* parameters for character map creation */
lpar_t host ;
lpar_t mapname ;
lpar_t mapdef ;
/* parameters for table creation */
lpar_t dbname;
lpar_t dbpars;
lpar_t dbstats;
dbname = lpar_create_str(LPAR_STR_DBDESCRIPTOR, "dbname");
host = lkt_host_lpar( "localhost", 5051);
/* population of other parameters omitted */
/* create transaction, storing tran id in tran variable */
err = lkt_tran_create(host, LPAR_NULL, &tran) ;
if ( ! DVKERR(err) ) {
/* create character map */
err = lkt_create_charmapT(host, mapname, tran, mapdef);
if ( ! DVKERR(err)) {
/* create table */
err =lkt_dbloadT(host, dbname, tran, dbpars, reclist, &dbstats);
}
/* commit or abort */
if ( DVKERR(err) ) {
err = lkt_tran_abort(host, tran, LPAR_NULL);
} else {
err = lkt_tran_commit(host, tran, LPAR_NULL);
}
}