#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    7
    Rep Power
    0

    Firebird Query Help


    Hello All.....

    Is there any way to get the affected row count after executing a delete query.

    example:

    Delete from TBL_NAME where Id=1 returning rows_affected ;

    i tried but shows error in query..

    Looking for your help..

    Thank You.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    14
    Rep Power
    0
    Hello,

    You could just take a COUNT using the same WHERE statement before you delete. For example:

    Code:
    SELECT COUNT(*) FROM TBL_NAME WHERE Id=1;
    As long as you use the same WHERE statement, that exact number of records will be deleted.

    Joe
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    43
    Rep Power
    5
    @aravindu: If you are fine doing that in PSQL (stored procedure, trigger, execute block), then check out the ROW_COUNT context variable. Usually, access components like IBObjects, IBDAC ... AFAIK also offers a property which gives you the "rows affected", but this isn't part of the SQL statement then.

    @joeflinthiggins: Only when running the SELECT and the DELETE in a single SNAPSHOT transaction.

    HTH.

IMN logo majestic logo threadwatch logo seochat tools logo