Update another table in database using RowId's returned from database events

243 Views Asked by At

Handling RowID's returned as part of DB events through a listener:

class DCNDemoListener implements DatabaseChangeListener
    {
      DBChangeNotification demo;
      DCNDemoListener(DBChangeNotification dem)
      {
        demo = dem;
      }
      public void  onDatabaseChangeNotification(DatabaseChangeEvent e)
      {
        System.out.println(e.toString());
      }
    }

For Example: Below are the values returned from database on DML operation

ROW: operation=UPDATE, ROWID=AAASjgAABAAAVapAAA

Using the above ROWID's I want to update/insert into another table in database. How do I do this? Do I have first store the RowId's in cache or is there any other way to insert/update using queries

1

There are 1 best solutions below

1
On

Inserting into another table using SQL :

Insert into table2 (column1,column2,....) (select column1,column2,.... from table1 where rowid = retrived_rowid);

If you want to use C# to insert into the second table using the rowids from the first table, you have to somehow persist the data in your application and then read your array/list and insert the data into the other table one tuple at a time. There's a method in ODP.net to insert multiple lines into a table in batch mode.

You can only update your original table with the retrieved rowids, since rowids are the physical row identifier and it's unique for each tuple in the database.