1 | try↵ | | 1 | try↵
|
2 | {↵ | | 2 | {↵
|
|
3 | Statement stat = _session.getSQLConnection().createStatement();↵ | | 3 | ↵
|
|
4 | SessionInternalFrame sessMainFrm = _session.getSessionInternalFrame();↵ | | 4 | IDatabaseObjectInfo[] dbObjs = _session.getSessionInternalFrame().getObjectTreeAPI().getSelectedDatabaseObjects();↵
|
|
5 | IDatabaseObjectInfo[] dbObjs = sessMainFrm.getObjectTreeAPI().getSelectedDatabaseObjects();↵ | | 5 | Statement stat = _session.getSQLConnection().createStatement();↵
|
|
|
6 | StringBuffer script = new StringBuffer();↵ | | 6 | StringBuffer script = new StringBuffer();↵
|
7 | for (int i = 0; i < dbObjs.length; i++)↵ | | 7 | for (int i = 0; i < dbObjs.length; i++)↵
|
8 | {↵ | | 8 | {↵
|
9 | ITableInfo ti = (ITableInfo) dbObjs[i];↵ | | 9 | IProcedureInfo pi = (IProcedureInfo) dbObjs[i];↵
|
|
10 | ///////////////////////////////////////////////////////////↵ | | 10 | ///////////////////////////////////////////////////////////↵
|
11 | // IBM DB 2 specific code to read view definitions.↵ | | 11 | // SybaseASE specific code to read procedure definitions.↵
|
12 | String sql =↵ | | 12 | String sql =↵
|
13 | "SELECT TEXT " +↵ | | 13 | "Select text " +↵
|
14 | "FROM SYSIBM.SYSVIEWS " +↵ | | 14 | "from sysobjects inner join syscomments on syscomments.id = sysobjects.id " +↵
|
15 | "WHERE NAME = '" + ti.getSimpleName() + "'";↵ | | 15 | "where name = '" + pi.getSimpleName().replace(";1", "") + "'";↵
|
|
16 | ResultSet res = stat.executeQuery(sql);↵ | | 16 | ResultSet res = stat.executeQuery(sql);↵
|
|
17 | res.next();↵ | | 17 | while(res.next()↵
|
|
| | | 18 | )↵
|
| | | 19 | {↵
|
18 | script.append(res.getString("TEXT"));↵ | | 20 | script.append(res.getString("↵
|
| | | 21 | text")); ↵
|
| | | 22 | }↵
|
19 | script.append(getStatementSeparator());↵ | | 23 | script.append(getStatementSeparator());↵
|
20 | res.close();↵ | | 24 | res.close();↵
|
21 | //↵ | | 25 | //↵
|
22 | ///////////////////////////////////////////////////////////↵ | | 26 | ///////////////////////////////////////////////////////////↵
|
23 | }↵ | | 27 | }↵
|
|
24 | stat.close();↵ | | 28 | stat.close();↵
|
|
| | | 29 | SessionInternalFrame sessMainFrm = _session.getSessionInternalFrame();↵
|
25 | sessMainFrm.getSQLPanelAPI().appendSQLScript(script.toString());↵ | | 30 | sessMainFrm.getSQLPanelAPI().appendSQLScript(script.toString());↵
|
26 | sessMainFrm.getSessionPanel().selectMainTab(ISession.IMainPanelTabIndexes.SQL_TAB);↵ | | 31 | sessMainFrm.getSessionPanel().selectMainTab(ISession.IMainPanelTabIndexes.SQL_TAB);↵
|
27 | }↵ | | 32 | }↵
|
28 | catch (Exception e)↵ | | 33 | catch (Exception e)↵
|
29 | {↵ | | 34 | {↵
|
30 | throw new RuntimeException(e);↵ | | 35 | throw new RuntimeException(e);↵
|
31 | } | | 36 | }
|