01: package net.sourceforge.squirrel_sql.plugins.informix.tab;
02:
03: /*
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: */
19: import java.sql.PreparedStatement;
20: import java.sql.SQLException;
21:
22: import net.sourceforge.squirrel_sql.client.session.ISession;
23: import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.BasePreparedStatementTab;
24: import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
25: import net.sourceforge.squirrel_sql.fw.util.StringManager;
26: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
27:
28: /**
29: * This class will display the details for an Informix index.
30: *
31: * @author <A HREF="mailto:jmheight@users.sourceforge.net">Jason Height</A>
32: */
33: public class IndexDetailsTab extends BasePreparedStatementTab {
34: private static final StringManager s_stringMgr = StringManagerFactory
35: .getStringManager(IndexDetailsTab.class);
36:
37: /**
38: * This interface defines locale specific strings. This should be
39: * replaced with a property file.
40: */
41: private interface i18n {
42: // i18n[IndexDetailsTab.title=Details]
43: String TITLE = s_stringMgr.getString("IndexDetailsTab.title");
44: // i18n[IndexDetailsTab.hint=Display index details]
45: String HINT = s_stringMgr.getString("IndexDetailsTab.hint");
46: }
47:
48: /** SQL that retrieves the data. */
49: private static final String SQL = "SELECT T1.owner AS index_owner, "
50: + " T1.idxname AS index_name, "
51: + " T2.owner AS table_owner, "
52: + " T2.tabname AS table_name, "
53: + " case T1.clustered "
54: + " when 'C' then 'CLUSTERED' "
55: + " else 'NON-CLUSTERED' "
56: + " end AS index_type, "
57: + " case T1.idxtype "
58: + " when 'U' then 'UNIQUE' "
59: + " else 'NON-UNIQUE' "
60: + " end AS uniqueness, "
61: + " T3.dbspace AS table_space, "
62: + " T4.fextsiz AS first_extent, "
63: + " T4.nextsiz AS next_extent, "
64: + " ( "
65: + " SELECT COUNT(*) "
66: + " FROM sysmaster:informix.sysptnext "
67: + " WHERE pe_partnum = T3.partn "
68: + " ) AS num_extents, "
69: + " T4.nptotal AS pages_total, "
70: + " T4.npused AS pages_used "
71: + "FROM informix.sysindices AS T1, "
72: + " informix.systables AS T2, "
73: + " informix.sysfragments AS T3, "
74: + " sysmaster:informix.sysptnhdr AS T4 "
75: + "WHERE T1.tabid > 99 "
76: + "AND T2.tabid = T1.tabid "
77: + "AND T3.tabid = T1.tabid "
78: + "AND T3.indexname = T1.idxname "
79: + "AND T4.partnum = T3.partn "
80: + "AND T1.owner = ? "
81: + "AND T1.idxname = ? "
82: + "ORDER BY 2 ";
83:
84: public IndexDetailsTab() {
85: super (i18n.TITLE, i18n.HINT, true);
86: }
87:
88: protected PreparedStatement createStatement() throws SQLException {
89: ISession session = getSession();
90: PreparedStatement pstmt = session.getSQLConnection()
91: .prepareStatement(SQL);
92: IDatabaseObjectInfo doi = getDatabaseObjectInfo();
93: pstmt.setString(1, doi.getSchemaName());
94: pstmt.setString(2, doi.getSimpleName());
95: return pstmt;
96: }
97: }
|