1 | public class IndexSourceTab extends FormattedSourceTab↵ | | 1 | public class TriggerSourceTab extends FormattedSourceTab↵
|
2 | {↵ | | 2 | {↵
|
|
| | | 3 | /** Logger for this class. */↵
|
| | | 4 | private final static ILogger s_log =↵
|
| | | 5 | LoggerController.createLogger(TriggerSourceTab.class);↵
|
| | | 6 | ↵
|
3 | /** SQL that retrieves the source of an index. */↵ | | 7 | /** SQL that retrieves the source of a stored procedure. */↵
|
4 | private static String SQL =↵ | | 8 | private static String SQL =↵
|
5 | "select " +↵ | | 9 | "↵
|
6 | "'create '||index_type_name||' '||index_name||' ON '||table_name||'('||column_name||')' " +↵ | | |
|
7 | "from INFORMATION_SCHEMA.INDEXES " +↵ | | |
|
8 | "where table_schema = ?↵ | | 10 | SELECT trigger_defs.text " +↵
|
| | | 11 | "FROM sysobjects tables , sysobjects triggers, syscomments trigger_defs " +↵
|
| | | 12 | "where triggers.type = 'TR' " +↵
|
| | | 13 | "and triggers.id = trigger_defs.id " +↵
|
9 | " +↵ | | 14 | "and triggers.deltrig = tables.id " +↵
|
10 | "and index_name = ? ";↵ | | 15 | "and tables.loginame = ? " +↵
|
11 | ↵ | | 16 | ↵
|
12 | /** Logger for this class. */↵ | | |
|
13 | private final static ILogger s_log =↵ | | |
|
14 | LoggerController.createLogger(ViewSourceTab.class);↵ | | |
|
| | | 17 | // TODO: figure out how to get then name of the table that the trigger ↵
|
| | | 18 | // is on. ↵
|
| | | 19 | //"and tables.name = ? " +↵
|
| | | 20 | "and triggers.name = ? ";↵
|
| | | 21 | ↵
|
15 | public IndexSourceTab(String hint, String stmtSep)↵ | | 22 | public TriggerSourceTab(String hint, String stmtSep)↵
|
16 | {↵ | | 23 | {↵
|
17 | super(hint);↵ | | 24 | super(hint);↵
|
18 | super.setCompressWhitespace(true);↵ | | 25 | super.setCompressWhitespace(true);↵
|
19 | super.setupFormatter(stmtSep, null); ↵ | | 26 | super.setupFormatter(stmtSep, null);↵
|
20 | }↵ | | 27 | }↵
|
|
21 | protected PreparedStatement createStatement() throws SQLException↵ | | 28 | protected PreparedStatement createStatement() throws SQLException↵
|
22 | {↵ | | 29 | {↵
|
23 | final ISession session = getSession();↵ | | 30 | final ISession session = getSession();↵
|
24 | final IDatabaseObjectInfo doi = getDatabaseObjectInfo();↵ | | 31 | final IDatabaseObjectInfo doi = getDatabaseObjectInfo();↵
|
|
25 | ISQLConnection conn = session.getSQLConnection();↵ | | |
|
26 | if (s_log.isDebugEnabled()) {↵ | | 32 | if (s_log.isDebugEnabled()) {↵
|
27 | s_log.debug("Running SQL for index source tab: "+SQL);↵ | | 33 | s_log.debug("Running SQL for View source tab: "+SQL);↵
|
28 | s_log.debug("schema name: "+doi.getSchemaName());↵ | | 34 | s_log.debug("Binding for param 1: "+doi.getCatalogName());↵
|
29 | s_log.debug("index name: "+doi.getSimpleName());↵ | | 35 | s_log.debug("Binding for param 2: "+doi.getSimpleName());↵
|
30 | }↵ | | 36 | }↵
|
| | | 37 | ↵
|
| | | 38 | ISQLConnection conn = session.getSQLConnection();↵
|
31 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵ | | 39 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵
|
32 | ↵ | | |
|
33 | pstmt.setString(1, doi.getSchemaName());↵ | | 40 | pstmt.setString(1, doi.getCatalogName());↵
|
34 | pstmt.setString(2, doi.getSimpleName());↵ | | 41 | pstmt.setString(2, doi.getSimpleName());↵
|
35 | return pstmt | | 42 | return pstmt
|