Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2008

    Unanswered: "inserted" and "deleted" tables - order of rows


    I have a question about the "inserted" and "deleted" tables which I am using in my triggers on an Adaptive Server Enterprise/15.0/.

    Let's say I have an UPDATE trigger trg1 on table tbl1. When I update 5 rows from tbl1, the tables "inserted" and "deleted" will both have 5 entries which I can use in my trigger trg1.

    In table "inserted" will be the "new" data - in "deleted" the "old".

    Now my question: Can I feel certain, that row 1 from table "inserted" is the new data and in row 1 from table "deleted" I can find its old?
    I want to be sure that row 1 from "inserted" belongs to row 1 from "deleted", and row 2 from "inserted" belongs to row 2 from "deleted" and so on..

    I've done some testing and it seems that they do, but maybe it was just coincidence or my test was too simple.


  2. #2
    Join Date
    May 2005
    South Africa
    Provided Answers: 1
    If you don't use an order by then you can't guarantee the sequence

  3. #3
    Join Date
    Apr 2008
    Iasi, Romania
    Provided Answers: 3
    If you have a PK on your table, I don't think you have to worry about records order - you may join the records from these two tables on the PK.

  4. #4
    Join Date
    Sep 2008
    The problem is that I can't order by any specific column or columns.
    I would need a column (or columns) that will not change.
    Normally that would be the primary key.
    But the primary key of my table, on with the trigger reacts, consists of several rows and each row could be updated.
    So if I order by them the "deleted" and "inserted" table will definite be different in some cases.
    I tried to work with ROWID but it seems that ROWID doesn't exists for ASE 15 but only for IQ.

Posting Permissions

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