public String getFieldDefinition( IValueMeta v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr) { String retval = ""; String fieldname = v.getName(); int length = v.getLength(); // Unused in vertica // int precision = v.getPrecision(); if (add_fieldname) retval += fieldname + " "; int type = v.getType(); switch (type) { case IValueMeta.TYPE_DATE: retval += "TIMESTAMP"; break; case IValueMeta.TYPE_BOOLEAN: retval += "BOOLEAN"; break; case IValueMeta.TYPE_NUMBER: case IValueMeta.TYPE_BIGNUMBER: retval += "FLOAT"; break; case IValueMeta.TYPE_INTEGER: retval += "INTEGER"; break; case IValueMeta.TYPE_STRING: retval += (length < 1) ? "VARCHAR" : "VARCHAR(" + length + ")"; break; default: retval += " UNKNOWN"; break; } if (add_cr) retval += CR; return retval; }
/** * Generates the SQL statement to drop a column from the specified table * * @param tablename The table to add * @param v The column defined as a value * @param tk the name of the technical key field * @param use_autoinc whether or not this field uses auto increment * @param pk the name of the primary key field * @param semicolon whether or not to add a semi-colon behind the statement. * @return the SQL statement to drop a column from the specified table */ @Override public String getDropColumnStatement( String tablename, IValueMeta v, String tk, boolean use_autoinc, String pk, boolean semicolon) { return "ALTER TABLE " + tablename + " DROP COLUMN " + v.getName() + CR; }
@Override public String getFieldDefinition( IValueMeta 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 IValueMeta.TYPE_DATE: retval += "DATETIME"; break; // Move back to Y/N for bug - [# 1538] Repository on MS ACCESS: error creating repository case IValueMeta.TYPE_BOOLEAN: if (supportsBooleanDataType()) { retval += "BIT"; } else { retval += "CHAR(1)"; } break; case IValueMeta.TYPE_NUMBER: case IValueMeta.TYPE_INTEGER: case IValueMeta.TYPE_BIGNUMBER: if (fieldname.equalsIgnoreCase(tk) || // Technical key fieldname.equalsIgnoreCase(pk) // Primary key ) // { if (use_autoinc) { retval += "COUNTER PRIMARY KEY"; } else { retval += "LONG PRIMARY KEY"; } } else { if (precision == 0) { if (length > 9) { retval += "DOUBLE"; } else { if (length > 5) { retval += "LONG"; } else { retval += "INTEGER"; } } } else { retval += "DOUBLE"; } } break; case IValueMeta.TYPE_STRING: if (length > 0) { if (length < 256) { retval += "TEXT(" + length + ")"; } else { retval += "MEMO"; } } else { retval += "TEXT"; } break; case IValueMeta.TYPE_BINARY: retval += " LONGBINARY"; break; default: retval += " UNKNOWN"; break; } if (add_cr) retval += CR; return retval; }
@Override public String getFieldDefinition( IValueMeta 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 IValueMeta.TYPE_DATE: retval += "DATETIME YEAR to FRACTION"; break; case IValueMeta.TYPE_BOOLEAN: if (supportsBooleanDataType()) { retval += "BOOLEAN"; } else { retval += "CHAR(1)"; } break; case IValueMeta.TYPE_NUMBER: case IValueMeta.TYPE_INTEGER: case IValueMeta.TYPE_BIGNUMBER: if (fieldname.equalsIgnoreCase(tk) || // Technical key fieldname.equalsIgnoreCase(pk) // Primary key ) { if (use_autoinc) { retval += "SERIAL8"; } else { retval += "INTEGER PRIMARY KEY"; } } else { if ((length < 0 && precision < 0) || precision > 0 || length > 9) { retval += "FLOAT"; } else { // Precision == 0 && length<=9 retval += "INTEGER"; } } break; case IValueMeta.TYPE_STRING: if (length >= CLOB_LENGTH) { retval += "CLOB"; } else { if (length < 256) { retval += "VARCHAR"; if (length > 0) { retval += "(" + length + ")"; } } else { if (length < 32768) { retval += "LVARCHAR"; } else { retval += "TEXT"; } } } break; default: retval += " UNKNOWN"; break; } if (add_cr) { retval += CR; } return retval; }