1 | public class ViewSourceTab extends BaseSourceTab↵ | | 1 | public class ProcedureSourceTab extends FormattedSourceTab↵
|
2 | {↵ | | 2 | {↵
|
3 | /** SQL that retrieves the source of a stored procedure. */↵ | | 3 | /** SQL that retrieves the source of a stored procedure. */↵
|
4 | private static String SQL =↵ | | 4 | private static String SQL =↵
|
5 | "select v.VIEWDEFINITION " +↵ | | 5 | "↵
|
6 | "from sys.SYSVIEWS v, sys.SYSTABLES t, sys.SYSSCHEMAS s " +↵ | | |
|
7 | "where v.TABLEID = t.TABLEID " +↵ | | |
|
8 | "and s.SCHEMAID = t.SCHEMAID↵ | | 6 | SELECT p.prosrc FROM pg_proc p, pg_namespace n " +↵
|
9 | " +↵ | | 7 | "where p.pronamespace = n.oid " +↵
|
10 | "and t.TABLENAME = ? " +↵ | | 8 | "and n.nspname = ? " +↵
|
11 | "and s.SCHEMANAME = ? ";↵ | | 9 | "and p.proname = ? ";↵
|
12 | ↵ | | 10 | ↵
|
13 | /** Logger for this class. */↵ | | 11 | /** Logger for this class. */↵
|
14 | private final static ILogger s_log =↵ | | 12 | private final static ILogger s_log =↵
|
15 | LoggerController.createLogger(ViewSourceTab.class);↵ | | 13 | LoggerController.createLogger(ProcedureSourceTab.class);↵
|
|
16 | public ViewSourceTab(String hint)↵ | | 14 | public ProcedureSourceTab(String hint)↵
|
17 | {↵ | | 15 | {↵
|
18 | super(hint);↵ | | 16 | super(hint);↵
|
19 | ↵ | | 17 | super.setCompressWhitespace(false);↵
|
20 | }↵ | | 18 | }↵
|
|
21 | protected PreparedStatement createStatement() throws SQLException↵ | | 19 | protected PreparedStatement createStatement() throws SQLException↵
|
22 | {↵ | | 20 | {↵
|
23 | final ISession session = getSession();↵ | | 21 | final ISession session = getSession();↵
|
24 | final IDatabaseObjectInfo doi = getDatabaseObjectInfo();↵ | | 22 | final IDatabaseObjectInfo doi = getDatabaseObjectInfo();↵
|
|
25 | ISQLConnection conn = session.getSQLConnection();↵ | | |
|
26 | if (s_log.isDebugEnabled()) {↵ | | 23 | if (s_log.isDebugEnabled()) {↵
|
27 | s_log.debug("Running View Source SQL: "+SQL);↵ | | 24 | s_log.debug("Running SQL for procedure source: "+SQL);↵
|
28 | s_log.debug("View Name="+doi.getSimpleName());↵ | | 25 | s_log.debug("schema="+doi.getSchemaName());↵
|
29 | s_log.debug("Schema Name="+doi.getSchemaName());↵ | | 26 | s_log.debug("procedure name="+doi.getSimpleName());↵
|
30 | }↵ | | 27 | }↵
|
31 | ↵ | | 28 | ↵
|
32 | ↵ | | 29 | ISQLConnection conn = session.getSQLConnection();↵
|
33 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵ | | 30 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵
|
34 | pstmt.setString(1, doi.getSimpleName()); // view name↵ | | 31 | // Postgres pg_proc table doesn't appear to have schema. I couldn't↵
|
| | | 32 | // locate another table to join with to get this info either.↵
|
35 | pstmt.setString(2, doi.getSchemaName()); // schema name↵ | | 33 | pstmt.setString(1, doi.getSchemaName());↵
|
| | | 34 | pstmt.setString(2, doi.getSimpleName());↵
|
36 | return pstmt | | 35 | return pstmt
|