I put a DbTransactionInterceptor and the execution fails between CreatingSavepoint and CreateSavepoint
The transaction SupportSavepoints is generated as true but the IBMConnection SupportSavepoint is false.
I am not sure if this might be the reason
I created a .dmp file and .flw respectively, but there is no meaningful information ...
The error message is not explained in the IBM documentation and no other traceable information is generated from the package.
I tried traceLevel=ALL but the license doesn't allow it.
------------------------------
Raja Adil
------------------------------
Original Message:
Sent: Wed May 17, 2023 02:14 AM
From: Archana Soni
Subject: IBM DB2 ERROR when Transaction SaveChanges EF CORE for .NET 6
Hi Albert,
Thanks for reaching out to us..
We tried to reproduce the issue but could not reproduce it in our house.
We implemented Console app which targets .NET 6.0, EF Core package 6.0.0.300 and LUW Server
Application contains table which has 2 column 1. ID integer type and 2. Name String type..
Here is sample code which we tried:
var ctx = new MyContext();using (var trans = ctx.Database.BeginTransaction()){ try { //ctx.SVPTAB1s.Add(new SVPTAB1 { ID = 102, Name = "archana" }); var q = ctx.SVPTAB1s.Where(s => s.ID == 101).FirstOrDefault(); q.Name = "XYZ"; trans.CreateSavepoint("MySavePoint"); var q1 = ctx.SVPTAB1s.Where(s => s.ID == 102).FirstOrDefault(); q1.Name = "ABC"; ctx.SaveChanges(); trans.Commit(); } catch (Exception e) { trans.Rollback(); throw; }}
Could you share following data points to investigate further..
1. What is target server details ?
2. Could you please share non confidential Repro app along with dummy database objects.? If you can not share the requested data here Please reach out to IBM Support team that will expedite the process as well...
Regards,
Archana
------------------------------
Archana Soni
Original Message:
Sent: Fri May 12, 2023 06:17 PM
From: Albert Sosa
Subject: IBM DB2 ERROR when Transaction SaveChanges EF CORE for .NET 6
I migrated from 3.1 to 6.0 and I have an issue every time I do Context.SaveChanges() after modifications made inside a Transaction using BOSContext.Database.BeginTransaction() .. It was working fine in 3.1.
Error:
IBM.Data.Db2.DB2Exception: 'ERROR [42601] [IBM][DB2] SQL0104N An unexpected token "<END-OF-STATEMENT>" was found following "". Expected tokens may include: "ON UNIQUE".'
Code example:
using (var transaction = SomeContext.Database.BeginTransaction()){
try{
var obj1 = SomeContext.SomeTable.Where(x => x.SomeFieldId == 1).FirstOrDefault()
obj1.SomeFieldToUpdate= "New Value 1";
var obj2 = SomeContext.SomeTable.Where(x => x.SomeFieldId == 2).FirstOrDefault()
obj2.SomeFieldToUpdate= "New Value 2";
BOSContext.SaveChanges(); //=> Fails here
transaction.Commit();
} catch (Exception){
transaction.Rollback();
throw;
}
}
I had to change the license to support 11.5 and to be compatible with 6.0.300
The connection string is the same as before...
Transactions work as long as you don't do SaveChanges to persist data
SaveChanges work if they are not inside a transaction.
I put a DbTransactionInterceptor and the execution fails between CreatingSavepoint and CreateSavepoint ... The transaction SupportSavepoints is generated as true but the IBMConnection SupportSavepoint is false ... I am not sure if this might be the reason
I created a .dmp file and .flw respectively, but there is no meaningful information ...
The error message is not explained in the IBM documentation and no other traceable information is generated from the package. I tried traceLevel=ALL but the license doesn't allow it.
------------------------------
Albert Sosa
------------------------------