Link to home
Start Free TrialLog in
Avatar of Dovberman
DovbermanFlag for United States of America

asked on

Limit a string to a specific substring

I have a function that iterates through rows of a cursor.

Each row of the cursor is a comma delimited set of string valaues.

"Name1, Name2, Name3, Name4"
"Name1, Name2"
"Name1, Name2, Name3"

I need to iterate through the rows as follows:

Most of this in in pseudocode.

intCommaCount := 0;
FOR cur_rec in CUR_CURSOR
      LOOP
        select cur_rec.PL into strLetterNameGroup from dual;
           -- count the number of commas as intCommaCount
           if intCommaCount >=3  --"Name1, Name2, Name3, Name4" ;
                      --strLetterNamesGroup needs to be "Name1, Name2, Name3 ;
                     -- extract the substring only to the character to the left of the 3rd comma
           end if
     
      end loop;

  return strLetterNameGroup ;
END;
SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dovberman

ASKER

All solutions are excellent.  This will increase my knowledge of PL/SQL.

Thank you.