xdenser / node-firebird-libfbclient

Firebird SQL binding
MIT License
82 stars 34 forks source link

Update has no effect on database #119

Open dwome opened 3 years ago

dwome commented 3 years ago

Hello,

I am trying to update some values in my database, but the transaction shows no effect. Do you have an idea what I am doing wrong here?

var con = fb.createConnection();
con.connectSync('pwrhsb.gdb'), 'SYSDBA', 'masterkey', '');
const query = 'UPDATE OBJEKT SET BEZ = 'ABCDEFG' WHERE OB_KEY = 25984';

const transaction = con.startNewTransactionSync();
const result = transaction.prepareSync(query);

result.execInTransSync(transaction);
transaction.commitSync();
miiguelperes commented 3 years ago

I have same problem

miiguelperes commented 3 years ago

In my case I was not doing the commit or the disconect, this way it worked:

return new Promise((resolve, reject) => { var conn = fb.createConnection(); conn.connect(self.configuracoes.database,self.configuracoes.user,self.configuracoes.password,'',function(err){ if(self.reportError(err, query)) reject(err) ; conn.query(query, function(err,qres){ if(self.reportError(err, query)) reject(err) ; let obj = qres.fetchSync('all',true) conn.commit(function(err){ console.log("Commit done ", err); }); conn.disconnect(); resolve(obj) }); }); conn.on('error',function(error){ reject(error) console.log(error) });

});