oracle function- modification required

I have a function
CREATE OR REPLACE FUNCTION strip_bad (p_string IN VARCHAR2)
      RETURN VARCHAR2
    IS
       good_string VARCHAR2(62)
          := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ||
             'abcdefghijklmnopqrstuvwxyz' ||
             '1234567890';
    BEGIN
      RETURN
       TRANSLATE (p_string, 'T' ||
                              TRANSLATE ( p_string, '.' || good_string
                                                 ,  '.'
                                       ) -- find the bad characters
                         ,  'T');  -- remove the bad characters
  END;
/
This functions removes bad characters.

If the user enters
added more blood bags
its takes off the space and inserts as
addedmorebloodbags.
How can I modify this fucntion to make sure that spaces between words are not removed? Help appreciated.
LVL 6
anumosesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
Add a space to the 'good' characters:

...
:= ' ABCDEFGHIJKLMNOPQRSTUVWXYZ'
...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
anumosesAuthor Commented:
CREATE OR REPLACE FUNCTION strip_bad (p_string IN VARCHAR2)
      RETURN VARCHAR2
    IS
       good_string VARCHAR2(62)
          := ' ABCDEFGHIJKLMNOPQRSTUVWXYZ' ||
              ' abcdefghijklmnopqrstuvwxyz' ||
              ' 1234567890';
    BEGIN
      RETURN
       TRANSLATE (p_string, 'T' ||
                              TRANSLATE ( p_string, '.' || good_string
                                                 ,  '.'
                                       ) -- find the bad characters
                         ,  'T');  -- remove the bad characters
  END;
/
Like this?
0
slightwv (䄆 Netminder) Commented:
Looks good to me if that is the only thing you changed (adding a space before the 'ABC...'.

On your test database, try it.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

anumosesAuthor Commented:
I made the change and ran this

select strip_bad('I am ready to compile') from dual;

ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "HBC_DATA.STRIP_BAD", line 4
0
slightwv (䄆 Netminder) Commented:
I missed the definite width on the varchar2.

Change:
good_string VARCHAR2(62)

to:
good_string VARCHAR2(63)
0
anumosesAuthor Commented:
that worked. thanks.
0
anumosesAuthor Commented:
thanks again
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.