public void alterBaseColumn(String objectName, Database.ResourceType type, String childName, ParsedDataType datatype, boolean autoIncrement, boolean notNull) { MetadataFactory factory = DatabaseStore.createMF(this); BaseColumn column = null; if (type == Database.ResourceType.TABLE){ Table table = (Table)getSchemaRecord(objectName, type); assertGrant(Grant.Permission.Privilege.ALTER, Database.ResourceType.TABLE, table); column = table.getColumnByName(childName); if (column == null){ throw new ParseException(QueryPlugin.Util.getString("SQLParser.no_table_column_found", childName, table.getName())); //$NON-NLS-1$ } } else { Procedure proc = (Procedure)getSchemaRecord(objectName, type); assertGrant(Grant.Permission.Privilege.ALTER, Database.ResourceType.PROCEDURE, proc); column = proc.getParameterByName(childName); if (column == null){ throw new ParseException(QueryPlugin.Util.getString("SQLParser.no_proc_column_found", childName, proc.getName())); //$NON-NLS-1$ } } MetadataFactory.setDataType(datatype.getType(), column, factory.getDataTypes(), notNull); SQLParserUtil.setTypeInfo(datatype, column); if (notNull) { column.setNullType(Column.NullType.No_Nulls); } if (type == Database.ResourceType.TABLE){ //must be called after setDataType as that will pull the defaults ((Column)column).setAutoIncremented(autoIncrement); } }
public void alterBaseColumn(String objectName, Database.ResourceType type, String childName, ParsedDataType datatype, boolean autoIncrement, boolean notNull) { MetadataFactory factory = DatabaseStore.createMF(this); BaseColumn column = null; if (type == Database.ResourceType.TABLE){ Table table = (Table)getSchemaRecord(objectName, type); assertGrant(Grant.Permission.Privilege.ALTER, Database.ResourceType.TABLE, table); column = table.getColumnByName(childName); if (column == null){ throw new ParseException(QueryPlugin.Util.getString("SQLParser.no_table_column_found", childName, table.getName())); //$NON-NLS-1$ } } else { Procedure proc = (Procedure)getSchemaRecord(objectName, type); assertGrant(Grant.Permission.Privilege.ALTER, Database.ResourceType.PROCEDURE, proc); column = proc.getParameterByName(childName); if (column == null){ throw new ParseException(QueryPlugin.Util.getString("SQLParser.no_proc_column_found", childName, proc.getName())); //$NON-NLS-1$ } } MetadataFactory.setDataType(datatype.getType(), column, factory.getDataTypes(), notNull); SQLParserUtil.setTypeInfo(datatype, column); if (notNull) { column.setNullType(Column.NullType.No_Nulls); } if (type == Database.ResourceType.TABLE){ //must be called after setDataType as that will pull the defaults ((Column)column).setAutoIncremented(autoIncrement); } }