Results 1 to 5 of 5
  1. #1
    Join Date
    May 2014
    Posts
    3

    Unanswered: ON DELETE CASCADE query

    How do I get the list of all child tables and it's corresponding count of number of rows that got deleted when I use ON DELETE CASCADE option to delete the rows.

    An audit of the counts against every table whose rows got deleted.
    Table Master 100
    Table child1 50
    Table child2 5
    Table child3 30

  2. #2
    Join Date
    May 2014
    Posts
    3

    ON DELETE CASCADE query

    How do I get the list of all child tables and it's corresponding count of number of rows that got deleted when I use ON DELETE CASCADE option to delete the rows.

    An audit of the counts against every table whose rows got deleted.
    Table Master 100
    Table child1 50
    Table child2 5
    Table child3 30

  3. #3
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    You may accomplish this by writting a DELETE trigger. I don't think there is a query / SP to give you this.
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

  4. #4
    Join Date
    May 2014
    Posts
    3
    Hi aflorin27

    can you be more elaborative on DELETE trigger? How does it work? Who will have to do that? the programmer in the code or the DBA?

  5. #5
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    A trigger is written by the DBA / DB programmer. One of its uses is to populate audit tables, like you need. Basically, every time a row is deleted, the trigger will count the corresponding rows from the child tables and insert the results in a separate table - the audit table.

    More on triggers you can find on doc: IBM Knowledge Center
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

Posting Permissions

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