public static String pg_get_indexdef(CommandContext cc, int index_oid, short column_no, boolean pretty_bool) throws TeiidSQLException, SQLException { //TODO: account for function based index try (Connection c = cc.getConnection(); PreparedStatement ps = c.prepareStatement("select indkey_names[?] from pg_index where indexrelid = ?")) { //$NON-NLS-1$ ps.setShort(1, column_no); ps.setInt(2, index_oid); ps.execute(); ResultSet rs = ps.getResultSet(); String result = null; if (rs.next()) { result = rs.getString(1); } return result; } }
public static String formatType(org.teiid.CommandContext cc, int oid, int typmod) throws SQLException { Connection c = cc.getConnection(); try { PreparedStatement ps = c.prepareStatement("select typname from pg_catalog.pg_type where oid = ?"); //$NON-NLS-1$
public static String pg_get_constraintdef(org.teiid.CommandContext cc, int oid, boolean pretty) throws SQLException { //return a simple constraint def try (Connection c = cc.getConnection(); PreparedStatement ps = c.prepareStatement("select pkcolumn_name, pktable_schem, pktable_name, fkcolumn_name from REFERENCEKEYCOLUMNS where getoid(fk_uid) = ? order by KEY_SEQ")) { //$NON-NLS-1$ ps.setInt(1, oid); ps.execute(); ResultSet rs = ps.getResultSet(); String refTable = null; List<String> columnNames = new ArrayList<String>(); List<String> refColumnNames = new ArrayList<String>(); while (rs.next()) { if (refTable == null) { refTable = SQLStringVisitor.escapeSinglePart(rs.getString(2)) + SQLConstants.Tokens.DOT + SQLStringVisitor.escapeSinglePart(rs.getString(3)); } columnNames.add(SQLStringVisitor.escapeSinglePart(rs.getString(4))); refColumnNames.add(SQLStringVisitor.escapeSinglePart(rs.getString(1))); } if (refTable == null) { return null; } return "FOREIGN KEY (" + StringUtil.join(columnNames, ",")+ ") REFERENCES " + refTable + "("+ StringUtil.join(refColumnNames, ",") + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ } }
TeiidConnection conn = ctx.getConnection(); pstmt = conn.prepareStatement("select (proj4text like '%longlat%') from SYS.spatial_ref_sys where srid = ?"); //$NON-NLS-1$ pstmt.setInt(1, srid);
TeiidConnection conn = ctx.getConnection(); pstmt = conn.prepareStatement("select (proj4text like '%longlat%') from SYS.spatial_ref_sys where srid = ?"); //$NON-NLS-1$ pstmt.setInt(1, srid);
TeiidConnection conn = ctx.getConnection(); pstmt = conn.prepareStatement("select proj4text from SYS.spatial_ref_sys where srid = ?"); //$NON-NLS-1$ pstmt.setInt(1, srid);
TeiidConnection conn = ctx.getConnection(); pstmt = conn.prepareStatement("select proj4text from SYS.spatial_ref_sys where srid = ?"); //$NON-NLS-1$ pstmt.setInt(1, srid);
TeiidConnection conn = ctx.getConnection(); pstmt = conn.prepareStatement("select proj4text from SYS.spatial_ref_sys where srid = ?"); //$NON-NLS-1$ pstmt.setInt(1, srid);