1 | public class ProcedureSourceTab 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: seqno is technically not needed to display the source for the↵ | | |
|
7 | * stored procedure, however, on some versions of Informix it is an error to↵ | | |
|
8 | * order by a column that is not in the select list, yielding this↵ | | |
|
9 | * exception:↵ | | |
|
10 | * ↵ | | |
|
11 | * Error: ORDER BY column (seqno) 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 T1.procid, T2.data, T2.seqno " +↵ | | 7 | "SELECT viewtext " +↵
|
17 | "FROM informix.sysprocedures AS T1, informix.sysprocbody AS T2 " +↵ | | 8 | "FROM informix.systables AS T1, informix.sysviews AS T2 " +↵
|
18 | "WHERE procname = ? " +↵ | | 9 | "WHERE tabname = ? " +↵
|
19 | "AND T2.procid = T1.procid " +↵ | | 10 | "AND T2.tabid = T1.↵
|
20 | "AND datakey = 'T' " +↵ | | |
|
21 | "ORDER BY T1.procid, T2.seqno ";↵ | | 11 | tabid ";↵
|
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(ProcedureSourceTab.class);↵ | | 15 | LoggerController.createLogger(ViewSourceTab.class);↵
|
|
26 | public ProcedureSourceTab(String hint)↵ | | 16 | public ViewSourceTab(String hint)↵
|
27 | {↵ | | 17 | {↵
|
28 | super(hint);↵ | | 18 | super(hint);↵
|
29 | sourceType = STORED_PROC_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();↵
|
|
39 | ↵ | | 24 | ISQLConnection conn = session.getSQLConnection();↵
|
40 | if (s_log.isDebugEnabled()) {↵ | | 25 | if (s_log.isDebugEnabled()) {↵
|
41 | s_log.debug("Running SQL: "+SQL);↵ | | 26 | s_log.debug("Running View Source SQL: "+SQL);↵
|
42 | s_log.debug("procname="+doi.getSimpleName());↵ | | 27 | s_log.debug("View Name="+doi.getSimpleName());↵
|
43 | }↵ | | 28 | ↵
|
|
44 | ISQLConnection conn = session.getSQLConnection();↵ | | 29 | s_log.debug("Schema Name="+doi.getSchemaName());↵
|
| | | 30 | } ↵
|
45 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵ | | 31 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵
|
46 | pstmt.setString(1, doi.getSimpleName());↵ | | 32 | pstmt.setString(1, doi.getSimpleName());↵
|
47 | return pstmt;↵ | | 33 | return pstmt;↵
|
48 | | | 34 |
|