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 {
Assertion.failed("Cannot determine element or expression type"); //$NON-NLS-1$
}
}