package net.sourceforge.phpdt.sql.sql; import net.sourceforge.phpdt.sql.bookmarks.Bookmark; public class SQLHelper { public static int getSize(Bookmark current, String tableName) { SQLResults results = MultiSQLServer.getInstance().execute( current.getConnection(), "SELECT COUNT(*) FROM " + tableName); //$NON-NLS-1$ return Integer.parseInt(results.getElement(1, 1).toString()); } public static SQLResults getResults(Bookmark current, String query, int start, int end, int maxLength, String encoding) { return MultiSQLServer.getInstance().execute(current.getConnection(), query, start, end, maxLength, encoding); } public static String getFullTableName(Bookmark current, String table) { String schema = current.getSchema(); if (schema == null) return table; if (schema.equals("")) return table; //$NON-NLS-1$ return schema + "." + table; //$NON-NLS-1$ } /** * True if the type is Real (numeric and with decimal part) according to java.sql.Types * @param type * @return */ public static boolean isReal(int type) { return (type == java.sql.Types.DECIMAL || type == java.sql.Types.DOUBLE || type ==java.sql.Types.FLOAT || type == java.sql.Types.NUMERIC || type == java.sql.Types.REAL ); } /** * True if the type is Numeric according to java.sql.Types * @param type * @return */ public static boolean isNumeric(int type) { return (type == java.sql.Types.DECIMAL || type == java.sql.Types.DOUBLE || type ==java.sql.Types.FLOAT || type == java.sql.Types.NUMERIC || type == java.sql.Types.REAL || type == java.sql.Types.BIGINT || type == java.sql.Types.TINYINT || type == java.sql.Types.SMALLINT || type == java.sql.Types.INTEGER ); } /** * True if the type is textual according to java.sql.Types * @param type * @return */ public static boolean isText(int type) { return (type == java.sql.Types.CLOB || type == java.sql.Types.VARBINARY || type ==java.sql.Types.VARCHAR ); } }