Hi, > I see them on the method signature for the init method but this is hit when the triggers are set up.... not when the trigger is actually fired...
Yes. If you need to know the table name, you could keep that in a field within the trigger class. Regards, Thomas On Mon, May 11, 2015 at 11:14 AM, blu10 <[email protected]> wrote: > how does it provide the table name to the fire function?. I see them on > the method signature for the init method but this is hit when the triggers > are set up.... not when the trigger is actually fired.... or have i that > wrong?... > > On Monday, 11 May 2015 09:16:15 UTC+1, schmitzc wrote: >> >> Hi, >> >> org.h2.tools.TriggerAdapter (your Trigger should extend that class), >> provides the protected members schemaName and tableName. >> >> Kind regards >> >> Christoff Schmitz >> >> F I N A R I S >> Financial Software Partner GmbH >> Sömmerringstrasse 23 >> 60322 Frankfurt am Main >> >> Fon: +49 (0)69 / 254 98 - 24 >> Mobile: +49 (0)176 / 206 34 186 >> Fax: +49 (0)69 / 254 98 - 50 >> eMail: mailto:[email protected] >> www: http://www.finaris.de und http://www.rapidrep.com >> >> >> >> From: blu10 <[email protected]> >> To: [email protected] >> Date: 2015-05-11 10:12 >> Subject: [h2] Triggers, finding the table name that trigger fired >> against? >> Sent by: [email protected] >> ------------------------------ >> >> >> >> I have numerous triggers on my database and i can see the data being i'm >> entering being output on the console using the code below in the fire >> function. The problem is i cant see which table the trigger was fired >> against. >> Is there something obvious im missing.....? Id like to eventually output >> the table name with the data entered so i can see which tables are being >> updated. >> >> /** >> * This method is called for each triggered action. >> * >> * @param conn a connection to the database >> * @param oldRow the old row, or null if no old row is available >> (for >> * INSERT) >> * @param newRow the new row, or null if no new row is available >> (for >> * DELETE) >> * @throws SQLException if the operation must be undone >> */ >> @Override >> public void fire(Connection conn, >> Object[] oldRow, Object[] newRow) >> throws SQLException { >> BigDecimal diff = null; >> if (newRow != null) { >> >> for (int i =0; i < newRow.length; i++) { >> >> if (newRow[i] != null) { >> System.out.println("Col !"); >> System.out.println(newRow[i].toString()); >> } >> >> } >> >> } >> >> } >> >> -- >> You received this message because you are subscribed to the Google Groups >> "H2 Database" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to *[email protected]*. >> To post to this group, send email to *[email protected]*. >> Visit this group at *http://groups.google.com/group/h2-database* >> <http://groups.google.com/group/h2-database>. >> For more options, visit *https://groups.google.com/d/optout* >> <https://groups.google.com/d/optout>. >> >> >> >> ================================================================================================================ >> Disclaimer >> The information contained in this e - mail and any attachments ( together >> the "message") is intended for the addressee only and >> may contain confidential and/or privileged information. If you have >> received the message by mistake please delete it and notify >> the sender and do not copy or distribute it or disclose its contents to >> anyone. >> >> FINARIS Financial Software Partner GmbH, Sömmerringstr. 23, 60322 >> Frankfurt/Main, Germany >> Registered at Frankfurt/Main, HRB 52873, Managing Directors: Dipl. Inf. >> Hermann Friebel, Dipl. Ing. Kai Bächle, Dipl. Inf. Werner Märkl >> >> ================================================================================================================ >> > -- > You received this message because you are subscribed to the Google Groups > "H2 Database" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/h2-database. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/d/optout.
