This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

Table name from StorageEvent

General questions regarding the development with JVx.

Table name from StorageEvent

Postby lucdep » Fri Oct 11, 2019 10:19 am

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
lucdep
 
Posts: 53
Joined: Wed Oct 10, 2018 12:01 pm

Re: Table name from StorageEvent

Postby Support@SIB » Fri Oct 11, 2019 10:30 am

You have the method: getStorage

Simply use the storage information/metadata/...
User avatar
Support@SIB
 
Posts: 353
Joined: Mon Sep 28, 2009 1:56 pm

Re: Table name from StorageEvent

Postby lucdep » Fri Oct 11, 2019 12:40 pm

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
lucdep
 
Posts: 53
Joined: Wed Oct 10, 2018 12:01 pm

Re: Table name from StorageEvent

Postby lucdep » Fri Oct 11, 2019 5:14 pm

Hi,

Figured it out...

String sTableName = ((DBStorage)pEvent.getStorage()).getWritebackTable();
lucdep
 
Posts: 53
Joined: Wed Oct 10, 2018 12:01 pm


Return to Development