class OracleDatabaseMeta extends BaseDatabaseMeta implements IDatabase {

    @Override
    public String getFieldDefinition(IValueMeta v, String tk, String pk, boolean useAutoinc,
                                     boolean addFieldname, boolean addCR) {
        StringBuilder retval = new StringBuilder(128);

        String fieldname = v.getName();
        int length = v.getLength();
        int precision = v.getPrecision();

        if (addFieldname) {
            retval.append(fieldname).append(' ');
        }

        int type = v.getType();
        switch (type) {
            case IValueMeta.TYPE_TIMESTAMP:
                if (supportsTimestampDataType()) {
                    retval.append("TIMESTAMP");
                } else {
                    retval.append("DATE");
                }
                break;
            case IValueMeta.TYPE_DATE:
                retval.append("DATE");
                break;
            case IValueMeta.TYPE_BOOLEAN:
                retval.append("CHAR(1)");
                break;
            case IValueMeta.TYPE_NUMBER:
            case IValueMeta.TYPE_BIGNUMBER:
                retval.append("NUMBER");
                if (length > 0) {
                    retval.append('(').append(length);
                    if (precision > 0) {
                        retval.append(", ").append(precision);
                    }
                    retval.append(')');
                }
                break;
            case IValueMeta.TYPE_INTEGER:
                retval.append("INTEGER");
                break;
            case IValueMeta.TYPE_STRING:
                if (length >= DatabaseMeta.CLOB_LENGTH) {
                    retval.append("CLOB");
                } else {
                    if (length == 1) {
                        retval.append("CHAR(1)");
                    } else if (length > 0 && length <= getMaxVARCHARLength()) {
                        retval.append("VARCHAR2(").append(length).append(')');
                    } else {
                        if (length <= 0) {
                            retval.append("VARCHAR2(2000)"); // We don't know, so we just use the maximum...
                        } else {
                            retval.append("CLOB");
                        }
                    }
                }
                break;
            case IValueMeta.TYPE_BINARY: // the BLOB can contain binary data.
                retval.append("BLOB");
                break;
            default:
                retval.append(" UNKNOWN");
                break;
        }

        if (addCR) {
            retval.append(Const.CR);
        }

        return retval.toString();
    }

}