Results 1 to 10 of 10
  1. #1
    Join Date
    Jan 2004
    Posts
    30

    Unanswered: Equivalent to @@TRANCOUNT in DB2

    I am migrating SQL Server procedures to DB2. Is there any equivalent to @@TRANCOUNT in DB2, how could i manage to get the eqivalent values in DB2.
    Regards
    Anderson

  2. #2
    Join Date
    Jan 2003
    Posts
    1,605
    Hi,

    Please read Must Read before posting for more tips how to write effective post.

    Hope this helps,
    Grofaty

  3. #3
    Join Date
    Jan 2004
    Posts
    30
    OK,
    I would like to know, is there any equivalent available in DB2(any version) for "@@TRANCOUNT"(global variable in SQL SERVER 2000) variable.

    Thanks.


    Originally posted by grofaty
    Hi,

    Please read Must Read before posting for more tips how to write effective post.

    Hope this helps,
    Grofaty

  4. #4
    Join Date
    Jan 2003
    Posts
    1,605
    Hi,

    Please specify what does the "@@TRANCOUNT" do? This is DB2 forum not SQL server forum, so people don't necessary know SQL server? I don't...

    From Must Read before posting thread:
    3) If your question is regarding the db2 equivalent of a feature in another database, please explain what that feature is all about (rather than saying, 'what is the db2 equivalent of oracle's INSTR' explain in a sentence or two what oracle's INSTR function is and ask how to do that in db2)

    Grofaty

  5. #5
    Join Date
    Jan 2004
    Posts
    30
    Hi Grofaty,

    In SQL Server @@TRANCOUNT Variable returns the number of active transactions for the current connection.

    Return Types = integer

    The BEGIN TRANSACTION statement increments @@TRANCOUNT by 1. ROLLBACK TRANSACTION decrements @@TRANCOUNT to 0, except for ROLLBACK TRANSACTION savepoint_name, which does not affect @@TRANCOUNT. COMMIT TRANSACTION or COMMIT WORK decrement @@TRANCOUNT by 1.

    Thanks...


    Originally posted by grofaty
    Hi,

    Please specify what does the "@@TRANCOUNT" do? This is DB2 forum not SQL server forum, so people don't necessary know SQL server? I don't...

    From Must Read before posting thread:
    3) If your question is regarding the db2 equivalent of a feature in another database, please explain what that feature is all about (rather than saying, 'what is the db2 equivalent of oracle's INSTR' explain in a sentence or two what oracle's INSTR function is and ask how to do that in db2)

    Grofaty

  6. #6
    Join Date
    Jan 2004
    Posts
    30
    Hi,
    Is it possible to get the equivalent of @@TRANCOUNT(Global Variable in SQL SERVER) variable using Temp Table or Sequences in DB2?

    Regards
    Anderson...

    Originally posted by Anderson
    Hi Grofaty,

    In SQL Server @@TRANCOUNT Variable returns the number of active transactions for the current connection.

    Return Types = integer

    The BEGIN TRANSACTION statement increments @@TRANCOUNT by 1. ROLLBACK TRANSACTION decrements @@TRANCOUNT to 0, except for ROLLBACK TRANSACTION savepoint_name, which does not affect @@TRANCOUNT. COMMIT TRANSACTION or COMMIT WORK decrement @@TRANCOUNT by 1.

    Thanks...

  7. #7
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Originally posted by Anderson
    Hi Grofaty,

    In SQL Server @@TRANCOUNT Variable returns the number of active transactions for the current connection.

    Return Types = integer

    The BEGIN TRANSACTION statement increments @@TRANCOUNT by 1. ROLLBACK TRANSACTION decrements @@TRANCOUNT to 0, except for ROLLBACK TRANSACTION savepoint_name, which does not affect @@TRANCOUNT. COMMIT TRANSACTION or COMMIT WORK decrement @@TRANCOUNT by 1.

    Thanks...
    As far as I understand, any single connection can only have one Unit of Work (that is, transaction) active at a time.

    Therefore, an equivalent of that function would be an integer literal 1

    :-)

  8. #8
    Join Date
    Jan 2004
    Posts
    30
    Hi,
    You mean i can replace the @@TRANCOUNT variable occurance with an integer variable 1(one). i.e one active connection can be made at a time.

    Please Clear this one.
    Thanks in advance...



    Originally posted by n_i
    As far as I understand, any single connection can only have one Unit of Work (that is, transaction) active at a time.

    Therefore, an equivalent of that function would be an integer literal 1

    :-)

  9. #9
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Originally posted by Anderson
    Hi,
    You mean i can replace the @@TRANCOUNT variable occurance with an integer variable 1(one). i.e one active connection can be made at a time.

    Please Clear this one.
    Thanks in advance...
    You said earlier that
    In SQL Server @@TRANCOUNT Variable returns the number of active transactions for the current connection.
    In DB2 each connection can only have no more than one unit of work (transaction) active at a time. Each client process I believe can have only one connection to the database. Therefore, from within that process the number of active transactions will either be 1 or 0, depending on whether you have started a transaction or not.

    Other processes can connect to the same database and have active transactions. However, there's no function or variable that shows you a total number of transactions across all connections that the database is currently processing.

    I hope this helps.

  10. #10
    Join Date
    Feb 2004
    Posts
    9
    Hi -

    A process can certainly have more than one connection to the database. When you open a cursor with the "WITH HOLD" option is that considered a seperate transaction? What if you have more than of those cursors open?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •