Example #1
0
// BeginTransaction begins a new transaction. It accepts a boolean flag that
// indicates whether the transaction should be hard or not. A hard transaction
// is a transaction that provides physical synchronization in the device, while
// a non-hard transaction provides logical synchronization with the file
// system.
func (d *DB) BeginTransaction(hard bool) error {
	var cHard C.int32_t = 0
	if hard {
		cHard = 1
	}
	if C.kcdbbegintran(d.db, cHard) == 0 {
		msg := d.LastError()
		return KCError(fmt.Sprintf("Could not begin transaction: %s.", msg))
	}
	return nil
}
Example #2
0
func (kc *KCDB) BeginTran(hard bool) (err error) {
	var chard C.int32_t
	if hard {
		chard = 1
	} else {
		chard = 0
	}
	if C.kcdbbegintran(kc.db, chard) == 0 {
		err = kc.error()
	}
	return
}