Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get a function to return a value occuring after a character

564814Dec 14 2011 — edited Dec 14 2011
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;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 11 2012
Added on Dec 14 2011
3 comments
84 views