I have a custom function which is supposed to calculate upper and lower quartiles. I want to compute it in a following way:
SELECT QUARTILE_UTILS.GET_QUARTILE(0.25, YEAR_1_FTE),
QUARTILE_UTILS.GET_QUARTILE(0.75, YEAR_1_FTE)
FROM SOME_TABLE WHERE FIRM_ID=999;
So it looks like an aggregate function. It receives a number to calculate a quartule(.25 or .75) and a collection of numbers. So here is the function body:
create or replace PACKAGE BODY QUARTILE_UTILS AS
FUNCTION GET_QUARTILE(PERCENTILE NUMBER, DATASET NUMBERS_ARRAY) RETURN NUMBER
IS
REMINDER NUMBER := 0;
I SIMPLE_INTEGER := 0;
RESULT NUMBER := 0;
BEGIN
....
RETURN RESULT;
END;
END QUARTILE_UTILS;
And as you can see, I defined a custom data type. Here it is:
create or replace TYPE NUMBERS_ARRAY AS TABLE OF NUMBER;
However, it still doens't work. When I try to execute I receive such error:
PLS-306: wrong number or types of arguments in call to 'GET_QUARTILE'
As far, as I understand my definition of collection of number is incorrect. What I am doing wrong?