1 | public class MysqlViewSourceTab extends FormattedSourceTab↵ | | 1 | public class ViewSourceTab extends FormattedSourceTab↵
|
2 | {↵ | | 2 | {↵
|
3 | /** SQL that retrieves the source of a view. */↵ | | 3 | /** SQL that retrieves the source of a stored procedure. */↵
|
4 | private static String SQL =↵ | | 4 | private static String SQL =↵
|
5 | "SELECT VIEW_DEFINITION " +↵ | | 5 | "↵
|
6 | "FROM INFORMATION_SCHEMA.VIEWS " +↵ | | |
|
7 | "WHERE TABLE_SCHEMA↵ | | 6 | select text " +↵
|
| | | 7 | "from sysobjects " +↵
|
| | | 8 | "inner join syscomments on syscomments.id = sysobjects.id " +↵
|
8 | = ? " +↵ | | 9 | "where loginame = ? " +↵
|
9 | "AND TABLE_NAME = ? ";↵ | | 10 | "and name = ? ";↵
|
10 | ↵ | | 11 | ↵
|
11 | /** Logger for this class. */↵ | | 12 | /** Logger for this class. */↵
|
12 | private final static ILogger s_log =↵ | | 13 | private final static ILogger s_log =↵
|
13 | LoggerController.createLogger(MysqlViewSourceTab.class);↵ | | 14 | LoggerController.createLogger(ViewSourceTab.class);↵
|
|
14 | public MysqlViewSourceTab(String hint, String stmtSep)↵ | | 15 | public ViewSourceTab(String hint, String stmtSep)↵
|
15 | {↵ | | 16 | {↵
|
16 | super(hint);↵ | | 17 | super(hint);↵
|
17 | super.setupFormatter(stmtSep, null);↵ | | 18 | super.set↵
|
18 | super.setCompressWhitespace(true);↵ | | 19 | CompressWhitespace(false);↵
|
| | | 20 | super.setupFormatter(stmtSep, null); ↵
|
19 | }↵ | | 21 | }↵
|
|
20 | protected PreparedStatement createStatement() throws SQLException↵ | | 22 | protected PreparedStatement createStatement() throws SQLException↵
|
21 | {↵ | | 23 | {↵
|
22 | final ISession session = getSession();↵ | | 24 | final ISession session = getSession();↵
|
23 | final IDatabaseObjectInfo doi = getDatabaseObjectInfo();↵ | | 25 | final IDatabaseObjectInfo doi = getDatabaseObjectInfo();↵
|
|
24 | ISQLConnection conn = session.getSQLConnection();↵ | | 26 | ISQLConnection conn = session.getSQLConnection();↵
|
25 | if (s_log.isDebugEnabled()) {↵ | | 27 | if (s_log.isDebugEnabled()) {↵
|
26 | s_log.debug("Running SQL for View source tab: "+SQL);↵ | | 28 | s_log.debug("Running SQL for View source tab: "+SQL);↵
|
27 | s_log.debug("Binding catalog name "+doi.getCatalogName()+↵ | | 29 | s_log.debug("Binding for param 1: "+doi.getCatalogName()↵
|
28 | " as first bind value");↵ | | 30 | );↵
|
29 | s_log.debug("Binding table name "+doi.getSimpleName()+↵ | | 31 | s_log.debug("Binding for param 2: "+doi.getSimpleName()↵
|
30 | " as second bind value"); ↵ | | |
|
31 | ↵ | | 32 | );↵
|
32 | }↵ | | 33 | }↵
|
33 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵ | | 34 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵
|
34 | ↵ | | 35 | ↵
|
35 | pstmt.setString(1, doi.getCatalogName());↵ | | 36 | pstmt.setString(1, doi.getCatalogName());↵
|
36 | pstmt.setString(2, doi.getSimpleName());↵ | | 37 | pstmt.setString(2, doi.getSimpleName());↵
|
37 | return pstmt | | 38 | return pstmt
|