Integer getSqlDataType()

in HSQL/src/org/hsqldb1/DITypeInfo.java [635:765]


    Integer getSqlDataType() {

        // values from SQL200n SQL CLI spec, or DITypes (which in turn borrows
        // first from java.sql.Types and then SQL200n SQL CLI spec) if there
        // was no corresponding value in SQL CLI
        switch (type) {

            case Types.ARRAY :
                return ValuePool.getInt(Types.SQL_ARRAY);        // SQL_ARRAY

            case Types.BIGINT :
                return ValuePool.getInt(Types.SQL_BIGINT);       // SQL_BIGINT

            case Types.BINARY :
                return ValuePool.getInt(Types.SQL_BLOB);         // fredt- was SQL_BIT_VARYING

            case Types.BOOLEAN :
                return ValuePool.getInt(Types.SQL_BOOLEAN);      // SQL_BOOLEAN

            case Types.BLOB :
                return ValuePool.getInt(Types.SQL_BLOB);         // SQL_BLOB

            case Types.CHAR :
                return ValuePool.getInt(Types.SQL_CHAR);         // SQL_CHAR

            case Types.CLOB :
                return ValuePool.getInt(Types.SQL_CLOB);         // SQL_CLOB

            case Types.DATALINK :
                return ValuePool.getInt(Types.SQL_DATALINK);     // SQL_DATALINK

            case Types.DATE :

                // NO:  This is the _concise_ code, whereas what we want to
                //      return here is the Data Type Code column value from
                //      Table 38 in the SQL 200n FCD.  This method is used
                //      by DatabaseInformationMain to list the sql type
                //      column in the SYSTEM_TYPEINFO table, which is specified
                //      by JDBC as the sql data type code, not the concise code.
                //      That is why there is a sql datetime sub column
                //      specified as well.
                // return ValuePool.getInt(Types.SQL_DATE);         // fredt - was SQL_DATETIME
                return ValuePool.getInt(Types.SQL_DATETIME);

            case Types.DECIMAL :
                return ValuePool.getInt(Types.SQL_DECIMAL);      // SQL_DECIMAL

            case Types.DISTINCT :
                return ValuePool.getInt(Types.SQL_UDT);          // SQL_UDT

            case Types.DOUBLE :
                return ValuePool.getInt(Types.SQL_DOUBLE);       // SQL_DOUBLE

            case Types.FLOAT :
                return ValuePool.getInt(Types.SQL_FLOAT);        // SQL_FLOAT

            case Types.INTEGER :
                return ValuePool.getInt(Types.SQL_INTEGER);      // SQL_INTEGER

            case Types.JAVA_OBJECT :
                return ValuePool.getInt(Types.JAVA_OBJECT);      // N/A - maybe SQL_UDT?

            case Types.LONGVARBINARY :
                return ValuePool.getInt(Types.SQL_BLOB);         // was SQL_BIT_VARYING

            case Types.LONGVARCHAR :
                return ValuePool.getInt(Types.SQL_CLOB);         //

            case Types.NULL :
                return ValuePool.getInt(Types.SQL_ALL_TYPES);    // SQL_ALL_TYPES

            case Types.NUMERIC :
                return ValuePool.getInt(Types.SQL_NUMERIC);      // SQL_NUMERIC

            case Types.OTHER :
                return ValuePool.getInt(Types.OTHER);            // N/A - maybe SQL_UDT?

            case Types.REAL :
                return ValuePool.getInt(Types.SQL_REAL);         // SQL_REAL

            case Types.REF :
                return ValuePool.getInt(Types.SQL_REF);          // SQL_REF

            case Types.SMALLINT :
                return ValuePool.getInt(Types.SQL_SMALLINT);     // SQL_SMALLINTEGER

            case Types.STRUCT :
                return ValuePool.getInt(Types.SQL_UDT);          // SQL_UDT

            case Types.TIME :

                // NO:  This is the _concise_ code, whereas what we want to
                //      return here is the Data Type Code column value from
                //      Table 38 in the SQL 200n FCD.  This method is used
                //      by DatabaseInformationMain to list the sql type
                //      column in the SYSTEM_TYPEINFO table, which is specified
                //      by JDBC as the sql data type code, not the concise code.
                //      That is why there is a sql datetime sub column
                //      specified as well.
                // return ValuePool.getInt(Types.SQL_TIME);         // fredt - was SQL_DATETIME
                return ValuePool.getInt(Types.SQL_DATETIME);

            case Types.TIMESTAMP :

                // NO:  This is the _concise_ code, whereas what we want to
                //      return here is the Data Type Code column value from
                //      Table 38 in the SQL CLI 200n FCD.  This method is used
                //      by DatabaseInformationMain to list the sql type
                //      column in the SYSTEM_TYPEINFO table, which is specified
                //      by JDBC as the sql data type code, not the concise code.
                //      That is why there is a sql datetime sub column
                //      specified as well.
                // return ValuePool.getInt(Types.SQL_TIMESTAMP);    // fredt - was SQL_DATETIME
                return ValuePool.getInt(Types.SQL_DATETIME);

            case Types.TINYINT :
                return ValuePool.getInt(Types.TINYINT);          // N/A

            case Types.VARBINARY :
                return ValuePool.getInt(Types.SQL_BLOB);         // SQL_BIT_VARYING

            case Types.VARCHAR :
                return ValuePool.getInt(Types.SQL_VARCHAR);      // SQL_VARCHAR

            case Types.XML :
                return ValuePool.getInt(Types.SQL_XML);          // SQL_XML

            default :
                return null;
        }
    }