1 | public class MysqlViewSourceTab 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 a view. */↵ | | 7 | /** SQL that retrieves the source of a stored procedure. */↵
|
4 | private static String SQL =↵ | | 8 | private static String SQL =↵
|
5 | "SELECT VIEW_DEFINITION " +↵ | | 9 | "SELECT trigger_defs.text " +↵
|
6 | "FROM INFORMATION_SCHEMA.VIEWS " +↵ | | 10 | "FROM ↵
|
7 | "WHERE TABLE_SCHEMA = ? " +↵ | | |
|
8 | "AND TABLE_NAME = ? ";↵ | | |
|
9 | ↵ | | |
|
10 | /** Logger for this class. */↵ | | |
|
11 | private final static ILogger s_log =↵ | | |
|
12 | LoggerController.createLogger(MysqlViewSourceTab.class);↵ | | |
|
|
13 | public MysqlView↵ | | 11 | sysobjects tables , sysobjects triggers, syscomments trigger_defs " +↵
|
| | | 12 | "where triggers.type = 'TR' " +↵
|
| | | 13 | "and triggers.id = trigger_defs.id " +↵
|
| | | 14 | "and triggers.deltrig = tables.id " +↵
|
| | | 15 | "and tables.loginame = ? " +↵
|
| | | 16 | // TODO: figure out how to get then name of the table that the trigger ↵
|
| | | 17 | // is on. ↵
|
| | | 18 | //"and tables.name = ? " +↵
|
| | | 19 | "and triggers.name = ? ";↵
|
| | | 20 | ↵
|
14 | SourceTab(String hint, String stmtSep)↵ | | 21 | public TriggerSourceTab(String hint, String stmtSep)↵
|
15 | {↵ | | 22 | {↵
|
16 | super(hint);↵ | | 23 | super(hint);↵
|
17 | super.setupFormatter(stmtSep, null);↵ | | 24 | super.set↵
|
18 | super.setCompressWhitespace(true↵ | | 25 | CompressWhitespace(true);↵
|
19 | );↵ | | 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 View source tab: "+SQL);↵ | | 33 | s_log.debug("Running SQL for View source tab: "+SQL);↵
|
28 | s_log.debug("Binding catalog name "+doi.getCatalogName()+↵ | | 34 | s_log.debug("Binding for param 1: "+doi.getCatalogName()↵
|
29 | " as first bind value");↵ | | 35 | );↵
|
30 | s_log.debug("Binding table name "+doi.getSimpleName()+↵ | | 36 | s_log.debug("Binding for param 2: "+doi.getSimpleName());↵
|
31 | ↵ | | 37 | }↵
|
32 | " as second bind value"); ↵ | | 38 | ↵
|
33 | ↵ | | |
|
34 | }↵ | | |
|
| | | 39 | ISQLConnection conn = session.getSQLConnection();↵
|
35 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵ | | 40 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵
|
36 | ↵ | | |
|
37 | pstmt.setString(1, doi.getCatalogName());↵ | | 41 | pstmt.setString(1, doi.getCatalogName());↵
|
38 | pstmt.setString(2, doi.getSimpleName());↵ | | 42 | pstmt.setString(2, doi.getSimpleName());↵
|
39 | return pstmt | | 43 | return pstmt
|