1 | public class ViewSourceTab extends BaseSourceTab↵ | | 1 | public class MysqlProcedureSourceTab 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 | "select routine_definition " +↵
|
6 | "from sys.SYSVIEWS v, sys.SYSTABLES t, sys.SYSSCHEMAS s " +↵ | | 6 | "from ↵
|
7 | "where v.TABLEID = t.TABLEID " +↵ | | |
|
8 | "and s.↵ | | 7 | information_schema.ROUTINES " +↵
|
9 | SCHEMAID = t.SCHEMAID " +↵ | | 8 | "where ROUTINE_SCHEMA = ? " +↵
|
10 | "and t.TABLENAME = ? " +↵ | | 9 | "and ↵
|
11 | "and s.SCHEMANAME = ? ";↵ | | 10 | ROUTINE_NAME = ? ";↵
|
12 | ↵ | | 11 | ↵
|
13 | /** Logger for this class. */↵ | | 12 | /** Logger for this class. */↵
|
14 | private final static ILogger s_log =↵ | | 13 | private final static ILogger s_log =↵
|
15 | LoggerController.createLogger(ViewSourceTab.class);↵ | | 14 | LoggerController.createLogger(MysqlProcedureSourceTab.class);↵
|
|
16 | public ViewSourceTab(String hint)↵ | | 15 | public MysqlProcedureSourceTab(String hint)↵
|
17 | {↵ | | 16 | {↵
|
18 | super(hint);↵ | | 17 | super(hint);↵
|
| | | 18 | super.setCompressWhitespace(false);↵
|
19 | }↵ | | 19 | }↵
|
|
20 | protected PreparedStatement createStatement() throws SQLException↵ | | 20 | protected PreparedStatement createStatement() throws SQLException↵
|
21 | {↵ | | 21 | {↵
|
22 | final ISession session = getSession();↵ | | 22 | final ISession session = getSession();↵
|
23 | final IDatabaseObjectInfo doi = getDatabaseObjectInfo();↵ | | 23 | final IDatabaseObjectInfo doi = getDatabaseObjectInfo();↵
|
|
24 | ISQLConnection conn = session.getSQLConnection();↵ | | |
|
25 | if (s_log.isDebugEnabled()) {↵ | | 24 | if (s_log.isDebugEnabled()) {↵
|
26 | s_log.debug("Running View Source SQL: "+SQL);↵ | | 25 | s_log.debug("Running SQL for procedure source: "+SQL);↵
|
27 | s_log.debug("View Name="+doi.getSimpleName());↵ | | 26 | s_log.debug("schema="+doi.getCatalogName());↵
|
28 | s_log.debug("Schema Name="+doi.getSchemaName());↵ | | 27 | s_log.debug("procedure name="+doi.getSimpleName());↵
|
29 | }↵ | | 28 | }↵
|
30 | ↵ | | 29 | ↵
|
| | | 30 | ISQLConnection conn = session.getSQLConnection();↵
|
31 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵ | | 31 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵
|
32 | pstmt.setString(1, doi.getSimpleName()); // view name↵ | | 32 | pstmt.setString(1, doi.getCatalogName());↵
|
33 | ↵ | | |
|
34 | pstmt.setString(2, doi.getSchemaName()); // schema name↵ | | 33 | pstmt.setString(2, doi.getSimpleName());↵
|
35 | return pstmt;↵ | | 34 | return pstmt;↵
|
36 | | | 35 |
|