if (data[2] == null) {
return null;
}
Object[] array = (Object[]) data[1];
ArrayType dt = (ArrayType) nodes[1].dataType;
Type elementType = dt.collectionBaseType();
int start = ((Number) Type.SQL_INTEGER.convertToType(session,
data[2], nodes[2].dataType)).intValue();
if (start <= 0) {
throw Error.error(ErrorCode.X_22003);
}
start--;
for (int i = start; i < array.length; i++) {
if (elementType.compare(session, data[0], array[i]) == 0) {
return ValuePool.getInt(i + 1);
}
}
return ValuePool.INTEGER_0;
}
case FUNC_SORT_ARRAY : {
if (data[0] == null) {
return null;
}
ArrayType dt = (ArrayType) dataType;
SortAndSlice exprSort = new SortAndSlice();
exprSort.prepareSingleColumn(1);
exprSort.sortDescending[0] = ((Number) data[1]).intValue()
== Tokens.DESC;
exprSort.sortNullsLast[0] = ((Number) data[2]).intValue()
== Tokens.LAST;
Object array = ArrayUtil.duplicateArray(data[0]);
dt.sort(session, array, exprSort);
return array;
}
case FUNC_ADD_MONTHS : {
if (data[0] == null) {