Page 1 of 1

Table name from StorageEvent

PostPosted: Fri Oct 11, 2019 10:19 am
by lucdep
Hi,

Can I somehow extract the name of the database table on which a StorageEvent happens?
In the following generic code I want to fill sTableName with that name

Code: Select all

public void doLog(StorageEvent pEvent) throws Exception
   {
      IBean oldRow = pEvent.getOld();
      IBean newRow = pEvent.getNew();
      Bean newLog = new Bean();
      String sUser = TriggerAPI.getCurrentUserName();
      Timestamp tTime = TriggerAPI.getCurrentTimestamp();
      String sTableName = pEvent. ?????????????;
      
      newLog.put("DBLOG_NEW", newRow.toString());
      newLog.put("DBLOG_OLD", oldRow.toString());
      newLog.put("SYS_CREATED_BY", sUser);
      newLog.put("SYS_CREATED_ON", tTime);
      newLog.put("TABLENAME", sTableName);
      
      DBStorage dblog = getDblog();
      
      dblog.insert(newLog);
   }


Thanks for your help.

Luc

Re: Table name from StorageEvent

PostPosted: Fri Oct 11, 2019 10:30 am
by Support@SIB
You have the method: getStorage

Simply use the storage information/metadata/...

Re: Table name from StorageEvent

PostPosted: Fri Oct 11, 2019 12:40 pm
by lucdep
Hi,

I don't see any reference to the name of the database table in Metadata, just to Columns...
So what would the correct line be?
Code: Select all

String sOrigin = pEvent.getStorage().getMetaData().????



Thanks,

Luc

Re: Table name from StorageEvent

PostPosted: Fri Oct 11, 2019 5:14 pm
by lucdep
Hi,

Figured it out...

String sTableName = ((DBStorage)pEvent.getStorage()).getWritebackTable();