I need to write a function to return the next value occurring after the ":" character in a column. If multiple values of ":" occurs then the function should return the sum of the next value occurring after each ":" in the column.
For example a rating value of 4:1 would return the value of 1. However, the rating of "5:1:1" should return a value of 1+1 = 2, and 6:2:1 will return of 2+1 = 3.
I have the below function skeletion and trying to figure out how the select statement will compute based on the position of : in the column and add the values and return the value back to function.
Function fn_check_internalrating(p_internalrating IN VARCHAR2)
RETURN number
IS
cnumber number;
cursor c1 is
select ................................
;
BEGIN
open c1;
fetch c1 into cnumber;
close c1;
RETURN cnumber;
EXCEPTION
WHEN OTHERS
THEN RETURN NULL;
END;