Results 1 to 11 of 11
  1. #1
    Join Date
    Jan 2014
    Posts
    10

    Unanswered: Update statement mystery

    Hello,

    I have got stuck in a very weird situation.

    I have trying to execute following update statement:

    update employee set name='Gaurav' where id=121;

    before and after this update the value of name remain same as previous i.e. 'Sunil', even if the result shows as 1 row effected.

    Please throw some light that where is the problem.

    Thanks i advance.

    Sany.

  2. #2
    Join Date
    Jul 2013
    Location
    Moscow, Russia
    Posts
    666
    Provided Answers: 55
    Hi,

    Did I get you correctly, that the last query below in the same session returns 'Sunil' without any error after the 1-st statement?

    update employee set name='Gaurav' where id=121;
    Select name from employee where id=121;

    If yes, this can happen if there is a trigger on this table / view, for example.
    Regards,
    Mark.

  3. #3
    Join Date
    Jan 2014
    Posts
    10
    yes it returns 'Sunil' in the same session where update is applied.

  4. #4
    Join Date
    Jan 2014
    Posts
    10
    Quote Originally Posted by sanygup View Post
    yes it returns 'Sunil' in the same session where update is applied.
    Mark you might be correct that any trigger is doing that. But if I update the value from client interface such as toad, value gets change successfully.

  5. #5
    Join Date
    May 2012
    Location
    Canberra, Australia
    Posts
    176
    Provided Answers: 6
    are you executing from the command line with no commit?
    Andy

    "All parts should go together without forcing. You must remember that the parts you are reassembling were disassembled by you. Therefore, if you can’t get them together again, there must be a reason. By all means, do not use hammer.” — IBM maintenance manual, 1975 "

  6. #6
    Join Date
    Jan 2014
    Posts
    10
    Quote Originally Posted by tafster View Post
    are you executing from the command line with no commit?
    No, I am using toad editor.

  7. #7
    Join Date
    May 2012
    Location
    Canberra, Australia
    Posts
    176
    Provided Answers: 6
    test it from the command line using a file input to see if it's something weird about Toad
    Andy

    "All parts should go together without forcing. You must remember that the parts you are reassembling were disassembled by you. Therefore, if you can’t get them together again, there must be a reason. By all means, do not use hammer.” — IBM maintenance manual, 1975 "

  8. #8
    Join Date
    Jan 2014
    Posts
    10
    Quote Originally Posted by tafster View Post
    test it from the command line using a file input to see if it's something weird about Toad
    I have checked using control center, same thing is happening.

  9. #9
    Join Date
    May 2012
    Location
    Canberra, Australia
    Posts
    176
    Provided Answers: 6
    As Mark mentioned, are there any triggers on that table?
    Andy

    "All parts should go together without forcing. You must remember that the parts you are reassembling were disassembled by you. Therefore, if you can’t get them together again, there must be a reason. By all means, do not use hammer.” — IBM maintenance manual, 1975 "

  10. #10
    Join Date
    May 2012
    Location
    Canberra, Australia
    Posts
    176
    Provided Answers: 6
    What version of DB2 and which O/S?
    Andy

    "All parts should go together without forcing. You must remember that the parts you are reassembling were disassembled by you. Therefore, if you can’t get them together again, there must be a reason. By all means, do not use hammer.” — IBM maintenance manual, 1975 "

  11. #11
    Join Date
    Sep 2004
    Posts
    15
    I ran into a similar problem some time back and later we found out that there was a trigger on the table that was updating the value of the column back to its original one from another table.

Tags for this Thread

Posting Permissions

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