class NetezzaDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface {

  @Override
  public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc,
    boolean add_fieldname, boolean add_cr ) {
    String retval = "";

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

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

    int type = v.getType();
    switch ( type ) {
      case ValueMetaInterface.TYPE_DATE:
        retval += "date";
        break;
      case ValueMetaInterface.TYPE_BOOLEAN:
        retval += "boolean";
        break;
      case ValueMetaInterface.TYPE_NUMBER:
      case ValueMetaInterface.TYPE_INTEGER:
      case ValueMetaInterface.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 ValueMetaInterface.TYPE_STRING:
        if ( length > MAX_CHAR_LEN ) {
          retval += "varchar(" + MAX_CHAR_LEN + ")";
        } else {
          retval += "varchar(" + length + ")";
        }
        break;
      default:
        retval += " UNKNOWN";
        break;
    }
    if ( add_cr ) {
      retval += Const.CR;
    }
    return retval;
  }

}