1 | public class TriggerSourceTab extends InformixSourceTab↵ | | 1 | public class ViewSourceTab extends InformixSourceTab↵
|
2 | {↵ | | 2 | {↵
|
3 | /** ↵ | | 3 | /** ↵
|
4 | * SQL that retrieves the source of a stored procedure.↵ | | 4 | SQL that retrieves the source of a stored procedure.↵
|
5 | * ↵ | | |
|
6 | * Note: datakey and seqno are technically not needed to display the source ↵ | | |
|
7 | * for the trigger source code, however, on some versions of Informix it ↵ | | |
|
8 | * is an error to order by a column that is not in the select list, ↵ | | |
|
9 | * yielding this exception:↵ | | |
|
10 | * ↵ | | |
|
11 | * Error: ORDER BY column (datakey) must be in SELECT list. ↵ | | |
|
12 | * SQLState: IX000↵ | | |
|
13 | * ErrorCode: -309↵ | | |
|
14 | */↵ | | 5 | */↵
|
15 | private static String SQL =↵ | | 6 | private static String SQL =↵
|
16 | "SELECT T2.data, T2.datakey, T2.seqno " +↵ | | 7 | "SELECT viewtext " +↵
|
17 | "FROM informix.systriggers AS T1, informix.systrigbody AS T2 " +↵ | | 8 | "FROM informix.systables AS T1, informix.sysviews AS T2 " +↵
|
18 | "WHERE trigname = ? " +↵ | | 9 | "WHERE tabname = ? " +↵
|
19 | "AND T2.trigid = T1.trigid " +↵ | | 10 | "AND T2.tabid = T1.tabid "↵
|
20 | "AND datakey IN ('D', 'A') " +↵ | | |
|
21 | "ORDER BY datakey DESC, seqno ";↵ | | 11 | ;↵
|
22 | ↵ | | 12 | ↵
|
23 | /** Logger for this class. */↵ | | 13 | /** Logger for this class. */↵
|
24 | private final static ILogger s_log =↵ | | 14 | private final static ILogger s_log =↵
|
25 | LoggerController.createLogger(TriggerSourceTab.class);↵ | | 15 | LoggerController.createLogger(ViewSourceTab.class);↵
|
|
26 | public TriggerSourceTab(String hint)↵ | | 16 | public ViewSourceTab(String hint)↵
|
27 | {↵ | | 17 | {↵
|
28 | super(hint);↵ | | 18 | super(hint);↵
|
29 | sourceType = TRIGGER_TYPE;↵ | | |
|
30 | }↵ | | |
|
|
31 | /**↵ | | |
|
32 | * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.BaseSourceTab#createStatement()↵ | | |
|
33 | */↵ | | |
|
34 | @Override↵ | | 19 | }↵
|
|
35 | protected PreparedStatement createStatement() throws SQLException↵ | | 20 | protected PreparedStatement createStatement() throws SQLException↵
|
36 | {↵ | | 21 | {↵
|
37 | final ISession session = getSession();↵ | | 22 | final ISession session = getSession();↵
|
38 | final IDatabaseObjectInfo doi = getDatabaseObjectInfo();↵ | | 23 | final IDatabaseObjectInfo doi = getDatabaseObjectInfo();↵
|
|
| | | 24 | ISQLConnection conn = session.getSQLConnection();↵
|
39 | if (s_log.isDebugEnabled()) {↵ | | 25 | if (s_log.isDebugEnabled()) {↵
|
40 | s_log.debug("Running SQL: "+SQL);↵ | | 26 | s_log.debug("Running View Source SQL: "+SQL);↵
|
41 | s_log.debug("trigname="+doi.getSimpleName());↵ | | 27 | s_log.debug("View Name="+doi.getSimpleName());↵
|
42 | }↵ | | 28 | ↵
|
43 | ISQLConnection conn = session.getSQLConnection();↵ | | 29 | s_log.debug("Schema Name="+doi.getSchemaName());↵
|
| | | 30 | } ↵
|
44 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵ | | 31 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵
|
45 | pstmt.setString(1, doi.getSimpleName());↵ | | 32 | pstmt.setString(1, doi.getSimpleName());↵
|
46 | return pstmt | | 33 | return pstmt
|