class NetezzaDatabaseMeta extends BaseDatabaseMeta implements IDatabase {

    @Override
    public String getFieldDefinition(IValueMeta v, String tk, String pk, boolean useAutoinc,
                                     boolean addFieldname, boolean addCr) {
        String retval = "";

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

        if (addFieldname) {
            retval += fieldname + " ";
        }

        int type = v.getType();
        switch (type) {
            case IValueMeta.TYPE_DATE:
                retval += "date";
                break;
            case IValueMeta.TYPE_BOOLEAN:
                retval += "boolean";
                break;
            case IValueMeta.TYPE_NUMBER:
            case IValueMeta.TYPE_INTEGER:
            case IValueMeta.TYPE_BIGNUMBER:
                if (length > 0) {
                    if (precision == 0) {
                        if (length <= 2) {
                            retval += "byteint";
                        } else if (length <= 4) {
                            retval += "smallint";
                        } else if (length <= 9) {
                            retval += "integer";
                        } else {
                            retval += "bigint";
                        }
                    } else {
                        if (length < 9) {
                            retval += "real";
                        } else if (length < 18) {
                            retval += "double";
                        } else {
                            retval += "numeric(" + length;
                            if (precision > 0) {
                                retval += ", " + precision;
                            }
                            retval += ")";
                        }
                    }
                }
                break;
            case IValueMeta.TYPE_STRING:
                if (length > MAX_CHAR_LEN) {
                    retval += "varchar(" + MAX_CHAR_LEN + ")";
                } else {
                    retval += "varchar(" + length + ")";
                }
                break;
            default:
                retval += " UNKNOWN";
                break;
        }
        if (addCr) {
            retval += Const.CR;
        }
        return retval;
    }

}