*/
private Object getColumnInType(int columnIndex,
Type targetType) throws SQLException {
Object[] rowData = getCurrent();
Type sourceType;
Object value;
checkColumn(columnIndex);
sourceType = resultMetaData.columnTypes[--columnIndex];
value = rowData[columnIndex];
if (trackNull(value)) {
return null;
}
if (sourceType.typeCode != targetType.typeCode) {
try {
value = targetType.convertToTypeJDBC(session, value,
sourceType);
} catch (Exception e) {
String stringValue = (value instanceof Number
|| value
instanceof String) ? value.toString()
: "instance of " + value.getClass().getName();
String msg = "from SQL type " + sourceType.getNameString()
+ " to " + targetType.getJDBCClassName()
+ ", value: " + stringValue;
Util.throwError(Error.error(ErrorCode.X_42561, msg));
}