Hi,
I have a requirement to process a batch of Insert statements in dashdb
and if some insert gives error and need to rollback all transaction
otherwise commit. I tried ibm_db node modules but unable to resolve my
problem. Could you please help me with some sample solution?
Some code snippet as below:
First I am beginning the transaction-
conn.beginTransaction()
var stmt = conn.prepareSync("insert into mytable values(?, ?)"); // mytable (c1 int, c2 varchar(20))
Now having a loop where I am creating params and binding them to above query statement.
stmt.bind(params);
Now
my requirement is if we have any issue with executing any of statement
and I will rollback all statements otherwise will commit.
I tried
multiple method - stmt.executeSync() or conn.commitTransaction() or
conn.rollbackTransaction().
If I put any wrong insert (ex
stmt.bind(['a', 'amit'])), it should rollback all previous transaction. But it doesn't rollback.
Can we do this using ibm_db node module?
Thanks,
Atul