nuintun/node-adodb

Transactions

franciscojunqueiralima opened this issue ยท 4 comments

Hello!!

I'm trying to use with transactions, but it seens that every time i call the execute function, the statment is committed.

The following code is not giving any error in the statment "BEGIN TRANSACTION". However the "COMMIT" statment is not running, it says that need to start a transaction first.

const ADODB = require('node-adodb');
const connection = ADODB.open('Provider=Microsoft.ACE.OLEDB.12.0;Data 
 Source=Database1.accdb;Persist Security Info=False;');`

const testTransaction = async() => {
    try {
        await connection.execute("BEGIN TRANSACTION");
        await connection.execute("COMMIT");
    } catch (err) {
        console.log(err);
    }    
};

testTransaction();

Is there any other way to do this?

Thank you and congrats for the package, awesome!

Up

I also hitting a snag on this one. My current project require me to connect to old school foxpro rather than mdb. Connecting to vfpoledb and query is very crisp. But, things not really goes well when executing insert. The solution is we need to alter null on each columns (which is not permited by my client) or SET NULL OFF before executing the INSERT. I tried but fail.

 async exec ()  {
    try {
        await conn.execute("SET NULL OFF")
        await conn.execute("INSERT INTO employees('code', 'name') VALUES ('123', 'test')")
    } catch (err) {
        console.log(JSON.stringify(err))
    }    
}

When run no error, but value not inserted to table.

I aslo tried:
await conn.execute("SET NULL OFF; INSERT INTO employees('code', 'name') VALUES ('123', 'test')")
but no luck.

Hope there is a workaround?

Hello!!

I'm trying to use with transactions, but it seens that every time i call the execute function, the statment is committed.

The following code is not giving any error in the statment "BEGIN TRANSACTION". However the "COMMIT" statment is not running, it says that need to start a transaction first.

const ADODB = require('node-adodb');
const connection = ADODB.open('Provider=Microsoft.ACE.OLEDB.12.0;Data 
 Source=Database1.accdb;Persist Security Info=False;');`

const testTransaction = async() => {
    try {
        await connection.execute("BEGIN TRANSACTION");
        await connection.execute("COMMIT");
    } catch (err) {
        console.log(err);
    }    
};

testTransaction();

Is there any other way to do this?

Thank you and congrats for the package, awesome!

@franciscojunqueiralima Try this fork. anasyy/node-adodb Package come with transactions. Work great!

 let inserts = []
 await conn.executeTrans(inserts)

@franciscojunqueiralima Try this fork. anasyy/node-adodb Package come with transactions. Work great!

 let inserts = []
 await conn.executeTrans(inserts)

Awesome man, i'm going to check it out. Thank you!

Sorry, the lib not yet support transaction, but it a good suggest.