List newValues = new ArrayList(values.size());
// check that # of variables == # of values
if(values.size() != insert.getVariables().size()) {
throw new QueryResolverException("ERR.015.008.0010", QueryPlugin.Util.getString("ERR.015.008.0010", insert.getVariables().size(), values.size())); //$NON-NLS-1$ //$NON-NLS-2$
}
Iterator valueIter = values.iterator();
Iterator varIter = insert.getVariables().iterator();
while(valueIter.hasNext()) {
// Walk through both elements and expressions, which should match up
Expression expression = (Expression) valueIter.next();
ElementSymbol element = (ElementSymbol) varIter.next();
if (!usingQuery) {
ResolverUtil.setDesiredType(expression, element.getType(), insert);
}
if(element.getType() != null && expression.getType() != null) {
String elementTypeName = DataTypeManager.getDataTypeName(element.getType());
if (!usingQuery) {
newValues.add(ResolverUtil.convertExpression(expression, elementTypeName, metadata));
} else if (element.getType() != expression.getType()
&& !DataTypeManager.isImplicitConversion(DataTypeManager.getDataTypeName(expression.getType()),
DataTypeManager.getDataTypeName(element.getType()))) {
//TODO: a special case here is a projected literal
throw new QueryResolverException(QueryPlugin.Util.getString("InsertResolver.cant_convert_query_type", new Object[] {expression, expression.getType().getName(), element, element.getType().getName()})); //$NON-NLS-1$
}
} else if (element.getType() == null && expression.getType() != null && !usingQuery) {
element.setType(expression.getType());
newValues.add(expression);
} else {