01: package net.sourceforge.squirrel_sql.plugins.oracle.tab;
02:
03: import java.sql.PreparedStatement;
04: import java.sql.SQLException;
05:
06: import net.sourceforge.squirrel_sql.client.session.ISession;
07: import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
08: import net.sourceforge.squirrel_sql.fw.util.StringManager;
09: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
10:
11: public class ViewSourceTab extends OracleSourceTab {
12: private static final StringManager s_stringMgr = StringManagerFactory
13: .getStringManager(ViewSourceTab.class);
14:
15: /**
16: * This interface defines locale specific strings. This should be
17: * replaced with a property file.
18: */
19: private interface i18n {
20: // i18n[oracle.diplayScriptDetails=Display script details]
21: String HINT = s_stringMgr
22: .getString("oracle.diplayScriptDetails");
23: }
24:
25: /** SQL that retrieves the data. */
26: private static final String SQL = "select 'CREATE OR REPLACE VIEW ' || VIEW_NAME ||' AS ', TEXT "
27: + "FROM SYS.ALL_VIEWS "
28: + "WHERE OWNER = ? AND VIEW_NAME = ? ";
29:
30: public ViewSourceTab() {
31: super (i18n.HINT);
32: }
33:
34: protected PreparedStatement createStatement() throws SQLException {
35: ISession session = getSession();
36: PreparedStatement pstmt = session.getSQLConnection()
37: .prepareStatement(SQL);
38: IDatabaseObjectInfo doi = getDatabaseObjectInfo();
39: pstmt.setString(1, doi.getSchemaName());
40: pstmt.setString(2, doi.getSimpleName());
41: return pstmt;
42: }
43: }
|