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