1 | public class TriggerSourceTab extends FormattedSourceTab↵ | | 1 | public class ViewSourceTab extends FormattedSourceTab↵
|
2 | {↵ | | 2 | {↵
|
3 | /** SQL that retrieves the source of a trigger. */↵ | | 3 | /** SQL that retrieves the source of a stored procedure. */↵
|
4 | private final static String SQL =↵ | | 4 | private static final String SQL =↵
|
5 | "select TEXT from↵ | | 5 | "SELECT TEXT " +↵
|
6 | SYSCAT.TRIGGERS " +↵ | | 6 | "FROM SYSCAT.VIEWS " +↵
|
7 | "where TABSCHEMA = ? " +↵ | | 7 | "WHERE VIEWSCHEMA = ? " +↵
|
8 | "and TRIGNAME = ? ";↵ | | 8 | "AND VIEWNAME = ? ";↵
|
9 | ↵ | | 9 | ↵
|
10 | /** SQL that retrieves the source of a trigger on DB2 on OS/400. */↵ | | 10 | /** SQL that retrieves the source of a stored procedure on OS/400 */↵
|
11 | private final static String OS2_400_SQL = ↵ | | 11 | private static final String OS_400_SQL = ↵
|
12 | "select action_statement " +↵ | | 12 | "select view_definition " +↵
|
13 | "from qsys2.systriggers " +↵ | | 13 | "from qsys2.sysviews " +↵
|
14 | "where trigger_schema = ? " +↵ | | 14 | "where table_schema = ? " +↵
|
15 | "and trigger_name = ? ";↵ | | 15 | "and table_name = ? ";↵
|
16 | ↵ | | 16 | ↵
|
17 | /** Logger for this class. */↵ | | 17 | /** Logger for this class. */↵
|
18 | private final static ILogger s_log =↵ | | 18 | private final static ILogger s_log =↵
|
19 | LoggerController.createLogger(TriggerSourceTab.class);↵ | | 19 | LoggerController.createLogger(ViewSourceTab.class);↵
|
20 | ↵ | | |
|
21 | ↵ | | |
|
| | | 20 | /** boolean to indicate whether or not this session is OS/400 */↵
|
22 | private boolean isOS2400 = false;↵ | | 21 | private boolean isOS400 = false;↵
|
| | | 22 | ↵
|
| | | 23 | ↵
|
| | | 24 | /**↵
|
| | | 25 | * Constructor↵
|
| | | 26 | * ↵
|
| | | 27 | * @param isOS400 whether or not we are connected to an OS/400 system↵
|
| | | 28 | */ ↵
|
23 | public TriggerSourceTab(String hint, boolean isOS2400, String stmtSep)↵ | | 29 | public ViewSourceTab(String hint, String stmtSep, boolean isOS400)↵
|
24 | {↵ | | 30 | {↵
|
25 | super(hint);↵ | | 31 | super(hint);↵
|
26 | super.setCompressWhitespace(true);↵ | | 32 | super.setCompressWhitespace(true);↵
|
27 | super.setupFormatter(stmtSep, null);↵ | | 33 | super.setupFormatter(stmtSep, null); ↵
|
28 | this.isOS2400 = isOS2400;↵ | | 34 | this.isOS400 = isOS400;↵
|
29 | }↵ | | 35 | }↵
|
|
30 | /**↵ | | 36 | /**↵
|
31 | * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.BaseSourceTab#createStatement()↵ | | 37 | * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.BaseSourceTab#createStatement()↵
|
32 | */↵ | | 38 | */↵
|
33 | @Override ↵ | | 39 | @Override ↵
|
34 | protected PreparedStatement createStatement() throws SQLException↵ | | 40 | protected PreparedStatement createStatement() throws SQLException↵
|
35 | {↵ | | 41 | {↵
|
36 | final ISession session = getSession();↵ | | 42 | final ISession session = getSession();↵
|
37 | final IDatabaseObjectInfo doi = getDatabaseObjectInfo();↵ | | 43 | final IDatabaseObjectInfo doi = getDatabaseObjectInfo();↵
|
|
38 | ↵ | | 44 | ISQLConnection conn = session.getSQLConnection();↵
|
39 | String sql = SQL;↵ | | 45 | String sql = SQL;↵
|
40 | if (isOS2400) {↵ | | 46 | if (isOS400) {↵
|
41 | sql = OS2_400_SQL;↵ | | 47 | sql = OS_400_SQL;↵
|
42 | }↵ | | |
|
43 | ↵ | | 48 | } ↵
|
44 | if (s_log.isDebugEnabled()) {↵ | | 49 | if (s_log.isDebugEnabled()) {↵
|
45 | s_log.debug("Running SQL: "+sql);↵ | | 50 | s_log.debug("Running SQL for View source tab: "+sql);↵
|
46 | s_log.debug("schema="+doi.getSchemaName());↵ | | 51 | s_log.debug("schema="+doi.getSchemaName());↵
|
47 | s_log.debug("trigname="+doi.getSimpleName());↵ | | 52 | s_log.debug("view name="+doi.getSimpleName());↵
|
48 | }↵ | | 53 | ↵
|
49 | ISQLConnection conn = session.getSQLConnection();↵ | | 54 | ↵
|
| | | 55 | }↵
|
50 | PreparedStatement pstmt = conn.prepareStatement(sql);↵ | | 56 | PreparedStatement pstmt = conn.prepareStatement(sql);↵
|
51 | pstmt.setString(1, doi.getSchemaName());↵ | | 57 | pstmt.setString(1, doi.getSchemaName());↵
|
52 | pstmt.setString(2, doi.getSimpleName());↵ | | 58 | pstmt.setString(2, doi.getSimpleName());↵
|
53 | return pstmt | | 59 | return pstmt
|