Help needed to run stored procedures within transactions

Posts   
 
    
cyn
User
Posts: 5
Joined: 05-May-2009
# Posted on: 05-May-2009 17:20:40   

Hi we are using llblgen version 2.6 with .Net 3.5. We would like to create a transaction with several stored procedures running inside. I don't find any sample code for doing this. Could you please post a sample code of how to create a transaction with several stored procedures call inside?

Thanks in advance!

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 05-May-2009 21:02:24   

Please see the documentation on transactions.

All stored procedure calls executed using a DataAccessAdaptor which has had transaction started on it will be run in the context of that transaction.

Matt

cyn
User
Posts: 5
Joined: 05-May-2009
# Posted on: 05-May-2009 21:49:27   

The documentation provides a sample code with entities and we need a sample using stored procedures. Could you please provide me a sample code with stored procedures?

Thanks!

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 05-May-2009 22:07:25   

From memory but should be enough to get you going. Just make sure you use the overload of the SP call that accepts the Data Access Adapter that yu have started the transaction with.



using (DataAccessAdapter da = new DataAccessAdapter())
{
   da.StartTransaction();
   ActionStoredProcedures.Proc1(da)
   ActionStoredProcedures.Proc2("Param1",da)
   da.CommitTransaction
}


Matt

cyn
User
Posts: 5
Joined: 05-May-2009
# Posted on: 06-May-2009 16:33:08   

Thanks for the response. We tried what you suggested but unfortunately is not working. As you can see in the code below we have a transaction with 3 stored procedures calls inside. When the third procedure fails the rollback instruction is executed but is not reflected on the database. We are using Oracle 9i as our backend. Could you please let me know what could be wrong? Is important for us to have this working in our application.

Thanks


Public Function InsertCourseAndDivision(ByVal inSigAction As System.String, ByVal inSigMeaning As System.String, ByVal inKeyid As System.String, ByVal inKeyuserid As System.String) As Integer

Using da As ISOtrainDAL.Oracle.DatabaseSpecific.DataAccessAdapter = New ISOtrainDAL.Oracle.DatabaseSpecific.DataAccessAdapter()

Try
            
          da.StartTransaction(IsolationLevel.ReadCommitted, "runTransactions")

          Oracle.DatabaseSpecific.ActionProcedures.CourseInsert(CourseCode, TrainingType, SubjectCode, GroupType, CourseRev, Description, Frequency, DurationTime, IssueDate, RevisionFreq, EffectiveDate, CostCourse, Materials, GmpRef, PreparedBy, CompMethod, PreReq, NextRevision, CourseStatus, DocRefCode, DocRefRev, DocRefLib, Equivalency, Expenses, Tasks, SelfTrain, Compliance, ApprovalReq, Notification, MaxFails, ModificationId, ModificationName, TrnCode, inSigAction, inSigMeaning, inKeyid, inKeyuserid, Generic, da)
          Oracle.DatabaseSpecific.ActionProcedures.CourseDivisionInsert("NA", CourseCode, ModificationId, ModificationName, TrnCode, inSigAction, inSigMeaning, inKeyid, inKeyuserid, da)
          Oracle.DatabaseSpecific.ActionProcedures.CourseDivisionInsert("SQL", CourseCode, ModificationId, ModificationName, TrnCode, inSigAction, inSigMeaning, inKeyid, inKeyuserid, da)

           da.Commit()
                        
           Return ISOtrainDAL.GenericDB.Response.Success
                        
Catch ex As Exception
                    
          da.Rollback()
          Return -2000
End Try

End Using
End Function


daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-May-2009 05:35:49   

What exact LLBLGen runtime library version are you using? (http://llblgen.com/tinyforum/Messages.aspx?ThreadID=7722)

David Elizondo | LLBLGen Support Team
cyn
User
Posts: 5
Joined: 05-May-2009
# Posted on: 07-May-2009 15:41:19   

I'm not sure what you are asking. I already said that we are using version 2.6. It was released on October 6, 2008

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 07-May-2009 18:11:15   

Using Oracle's version of SQL profiler, can you see the "BEGIN TRAN" and stored procedure calls being processed by the server ?

Matt

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 11-May-2009 15:23:27   

cyn wrote:

I'm not sure what you are asking. I already said that we are using version 2.6. It was released on October 6, 2008

We want to know if you're running the latest runtime library and templates. The designer's build date isn't the same as the runtime libs, which are updated more frequently.

Frans Bouma | Lead developer LLBLGen Pro
MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 12-May-2009 15:01:17   

The runtime library version is obtainable by rightclicking the SD.LLBLGen.Pro.ORMSupportClasses.NETxy.dll in windows explorer and then by selecting properties and the version tab. The version is then enlisted at the top as the fileversion. It has the typical format as 2.0.0.YYMMDD, or starting in 2007, the format 2.0.YY.MMDD

cyn
User
Posts: 5
Joined: 05-May-2009
# Posted on: 12-May-2009 15:25:16   

The runtime version is 2.6.09.0305

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 12-May-2009 20:54:54   

Ok ,so that is fairly recent. Going back to one of my earlier posts, Using Oracle's version of SQL profiler, can you see the "BEGIN TRAN" and stored procedure calls being processed by the server ?

It would really help us to be able to see this SQL trace in this instance as it may well shed some light on the issue.

You could also enable tracing onthe LLBLGen code as described here to see what is going on...

Thanks

Matt