1 | public class DerbyTableTriggerExtractorImpl implements ITableTriggerExtractor {↵ | | 1 | public class PostgresTableTriggerExtractorImpl implements ITableTriggerExtractor {↵
|
|
2 | /** Logger for this class */↵ | | 2 | /** Logger for this class */↵
|
3 | private final static ILogger s_log = ↵ | | 3 | private final static ILogger s_log = ↵
|
4 | LoggerController.createLogger(DerbyTableTriggerExtractorImpl.class);↵ | | 4 | LoggerController.createLogger(PostgresTableTriggerExtractorImpl.class);↵
|
5 | ↵ | | 5 | ↵
|
6 | /** The query that finds the triggers for a given table */↵ | | 6 | /** the query that extracts the trigger names for a given table */↵
|
7 | private static String SQL = ↵ | | 7 | private static final String triggerQuery = ↵
|
8 | "select tr.TRIGGERNAME " +↵ | | 8 | "select tr.tgname " +↵
|
9 | "from SYS.SYSTRIGGERS tr, SYS.SYSTABLES t, SYS.SYSSCHEMAS s " +↵ | | 9 | "from ↵
|
10 | "where tr.TABLEID = t.TABLEID↵ | | 10 | pg_catalog.pg_trigger tr, pg_catalog.pg_proc p, " +↵
|
| | | 11 | " pg_class c, pg_namespace n " +↵
|
| | | 12 | "where tr.tgfoid = p.oid " +↵
|
11 | " +↵ | | 13 | "and tr.tgrelid = c.oid " +↵
|
12 | "and s.SCHEMAID = t.SCHEMAID " +↵ | | 14 | "and c.relnamespace = n.oid " +↵
|
13 | "and t.TABLENAME = ? " +↵ | | 15 | "and n.nspname = ? " +↵
|
14 | "and s.SCHEMANAME = ? ";↵ | | 16 | "and c.relname = ? ";↵
|
15 | ↵ | | 17 | ↵
|
| | | 18 | ↵
|
16 | /**↵ | | 19 | /**↵
|
17 | * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.ITableTriggerExtractor#bindParamters(java.sql.PreparedStatement, net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo)↵ | | 20 | * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.ITableTriggerExtractor#bindParamters(java.sql.PreparedStatement, net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo)↵
|
18 | */↵ | | 21 | */↵
|
19 | public void bindParamters(PreparedStatement pstmt, IDatabaseObjectInfo dbo) ↵ | | 22 | public void bindParamters(PreparedStatement pstmt, IDatabaseObjectInfo dbo)↵
|
20 | throws SQLException ↵ | | 23 | throws SQLException ↵
|
21 | {↵ | | 24 | {↵
|
22 | if (s_log.isDebugEnabled()) {↵ | | 25 | if (s_log.isDebugEnabled()) {↵
|
23 | s_log.debug("Binding table name "+dbo.getSimpleName()+↵ | | 26 | s_log.debug("Binding schema name "+dbo.getSchemaName()+↵
|
24 | " as first bind value"); ↵ | | 27 | " as first bind value");↵
|
25 | s_log.debug("Binding schema name "+dbo.getSchemaName()+↵ | | 28 | s_log.debug("Binding table name "+dbo.getSimpleName()+↵
|
26 | " as second bind value");↵ | | 29 | " as second bind value"); ↵
|
27 | } ↵ | | 30 | } ↵
|
28 | pstmt.setString(1, dbo.getSimpleName());↵ | | 31 | pstmt.setString(1, dbo.getSchemaName());↵
|
29 | pstmt.setString(2, dbo.getSchemaName()); ↵ | | 32 | pstmt.setString(2, dbo.getSimpleName());↵
|
30 | }↵ | | 33 | }↵
|
|
31 | /**↵ | | 34 | /**↵
|
32 | * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.ITableTriggerExtractor#getTableTriggerQuery()↵ | | 35 | * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.ITableTriggerExtractor#getTableTriggerQuery()↵
|
33 | */↵ | | 36 | */↵
|
34 | public String getTableTriggerQuery() {↵ | | 37 | public String getTableTriggerQuery() {↵
|
35 | return SQL | | 38 | return triggerQuery
|