simulteneous transactions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amoldiego
    New Member
    • Jun 2007
    • 28

    simulteneous transactions

    Hi friends,


    I am using stuts,oracle(st ored procedure),jsp in my application.
    i have done all thing like writing stored procedure ,inserting data,validating data etc and finally data goes inside database.
    But friends my problem is that when i do two simultanious transaction in aplication then both trasaction are inserted into databases without giving me any exception which i expect from second transaction.

    for example

    Suppose
    I m login on two diffrent computers with same user id and doing following transactions simulteneously
    Txn A giving payemnt 2000
    Txn B also giving payemnt 2000

    Now due to some business logic i m expecting only one transaction should be insert into DB & other should raise me my exception

    My client not excepting Lock from start to end on data inserting stored procedure

    Now my databses stored procedure not contain any lock contain only commits

    how can i manage two independant transaction my application




    Thanks
    Amol
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    The best solution for your problem is to implement locks.

    u need to follow

    1.LOCK
    2.INSERT/UPDATE/DELTE
    3.COMMIT/ROLLBACK

    May i know what is the problem in implementing locks if that is your requirment.

    Comment

    • amoldiego
      New Member
      • Jun 2007
      • 28

      #3
      Originally posted by debasisdas
      The best solution for your problem is to implement locks.

      u need to follow

      1.LOCK
      2.INSERT/UPDATE/DELTE
      3.COMMIT/ROLLBACK

      May i know what is the problem in implementing locks if that is your requirment.

      Thanks debasisdas,
      Thanks for ur help ..Would u plz tell me the syntax of lock on insert statement ..
      and both my transaction are independent ..
      So could u help me out ...

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        follow these stops

        1.lock the table/s in exclusive mode
        2.go for insert.
        3.commit. (this unlock sthe table)

        write all these in side the oracle procedure.

        Comment

        • amoldiego
          New Member
          • Jun 2007
          • 28

          #5
          thanks ....please provide the syntex for loacking insert statement

          Comment

          • debasisdas
            Recognized Expert Expert
            • Dec 2006
            • 8119

            #6
            suppose your table is inventory , then

            1. lock table inventory in exclusive mode no wait;
            2.insert into inventory values(v1,v2,v3 ,........);
            3.commit;

            Comment

            • amoldiego
              New Member
              • Jun 2007
              • 28

              #7
              Thanks ........for ur vital help

              Comment

              • debasisdas
                Recognized Expert Expert
                • Dec 2006
                • 8119

                #8
                Hi
                amoldiego
                Welcome to TSDN.

                You have reached the right place for knowledge shairing.

                Here you will find a vast resource of related topics and code.

                Feel free to post more doubts/questions in the forum.

                But before that give a try from your side and if possible try to post what/how you have approached to solve the problem.

                It will help Experts in the forum in solving/underestanding your problem in a better way.

                Please follow the posting guidelines in every new post/reply.

                please specify your post/question clearly.

                Dont expect others to guess and solve your problem.

                Comment

                • amoldiego
                  New Member
                  • Jun 2007
                  • 28

                  #9
                  Suppose I created index on table . If i fired select statement on that table then how will come to know whether that index was fired or not ....

                  Comment

                  Working...