Results 1 to 6 of 6

Thread: For update of

  1. #1
    Join Date
    Sep 2008
    Location
    Toronto,Canada
    Posts
    655

    Unanswered: For update of

    Greetings,

    While studying code for some minor issue, I came across this select statement in a java script. This has surprised me, It does not seem to use a cursor.

    I tend to believe that I may not know, or I may have not used select this way.

    Can some one help me understand why FOR UPDATE OF was used in this statement ?

    SELECT * FROM Client_Acc WHERE Acc_Num = ? FOR UPDATE OF Cash_Amt,Real_Chips,Promo_Chips

    Help is appreciated. (searched online , all belong to cursor def).

    Regards

    DBFinder

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    That is used to obtain an IX (intent exclusive) lock on the row which means that no one else can obtain another IX lock, nor an X lock, but others can get a S (share) lock. The lock is released when a commit or rollback is issued.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  3. #3
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  4. #4
    Join Date
    Sep 2008
    Location
    Toronto,Canada
    Posts
    655
    Thanks


    DBFinder

  5. #5
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Quote Originally Posted by przytula_guy View Post
    That doc does not tell the whole story. FOR UPDATE can be used without a cursor and is often used to obtain a lock as I described above (while the application examines the contents of row in a select and does not want any others to update it, but want others to be able to read it).

    Also, it can be used for a positioned DELETE (in addition to UPDATE).
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  6. #6
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    or if you have problems with locking - look at optimistic locking in the doc..
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

Posting Permissions

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