Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...The forum looks great! You guys have done a fantastic job on arranging things there...Your site is very precise and fun to visit..."

Geography

Where in the world do Tek-Tips members come from?
getjbb (MIS)
18 Jun 12 13:14
Sorry, forgot subject line, again..

I have a string:

,off,on,off

I want to parse the data into an array. I found and tweaked (bolded) the following code, but the result was:

<blank line> (think this is coming from the first ',')
off
on
off
---------------------------------------
FUNCTION SPLIT (p_in_string VARCHAR2, p_delim VARCHAR2) RETURN t_array
IS

i number :=0;
pos number :=0;
lv_str varchar2(50) := p_in_string;

strings t_array;

BEGIN

-- determine first chuck of string
pos := instr(lv_str,p_delim,1,1);

-- while there are chunks left, loop
WHILE ( pos != 0) LOOP

-- increment counter
i := i + 1;

-- create array element for chuck of string
strings(i) := substr(lv_str,1,pos-1);

-- remove chunk from string
lv_str := substr(lv_str,pos+1,length(lv_str));

-- determine next chunk
pos := instr(lv_str,p_delim,1,1);

-- no last chunk, add to array
IF pos = 0 THEN

strings(i+1) := lv_str;

END IF;

END LOOP;

-- return array
RETURN strings;

END SPLIT;

-----------------------------------------------
getjbb
Dagon (MIS)
19 Jun 12 9:34
That sounds quite reasonable because effectively you have an empty element at the start of your string. You could just trim off the leading ',' with something like:

lv_str varchar2(50) := ltrim(p_in_string, ',');

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close