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