DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: How to check # of rows being updated

  1. #1
    Join Date
    May 2001
    Posts
    285

    How to check # of rows being updated

    Hi,

    In my PL/SQL code, I need to check the number of rows being updated by an update statement. How can I do that?

    To be compliant with Sql Server code, the logic I am going to adopt is (I used different color to represent different level of the IF..ELSE statemnt):

    UPDATE records where id = xxx
    IF got error returned
    THEN return -1
    ELSE

    [COLOR=dark-blue]
    check the number of rows being updated
    IF NO ROW being updated
    THEN
    [/COLOR]
    check if still get rows with id = xxx
    IF not THEN return 1// no row with id =xxx exist so nothing to update
    ELSE return 2 // rows with id=xxx were not updated
    END IF
    [COLOR=dark-blue]
    ELSE return 0 // rows are updated as they should be
    END IF
    [/COLOR]
    END IF


    In SQL, there is a global variable @@rowcount that shows the number of rows being affected by last statement. Since I can't find a counterpart in Oracle, how do I achieve this?

    Thanks,
    Elaine

  2. #2
    Join Date
    Mar 2001
    Posts
    42
    Hi,

    You can use SQL%ROWCOUNT to achieve that.

    Rgds,

    Saravanan.

  3. #3
    Join Date
    May 2001
    Posts
    285
    Thanks a lot! I will give that a shot!

    Originally posted by shravansam
    Hi,

    You can use SQL%ROWCOUNT to achieve that.

    Rgds,

    Saravanan.

Posting Permissions

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


Click Here to Expand Forum to Full Width