mukeshkt
asked on
DB2 stored procedure for removing the special character from db
hi all,
i want to have one stored procedure to remove special characters from dbase and print the report
and after that it will concatenate the other string and update the db.
i am using db2.
ex-- ASDBH&WE -----> ASDBHWE
ASDB_EW ----->ASDBEW
ASEDE%DV---->ASEDEDV
i want to have one stored procedure to remove special characters from dbase and print the report
and after that it will concatenate the other string and update the db.
i am using db2.
ex-- ASDBH&WE -----> ASDBHWE
ASDB_EW ----->ASDBEW
ASEDE%DV---->ASEDEDV
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here's the way I usually accomplish that kind of thing:
upda
set text = translate(text,' ','&_%', ' ');
I find that much simpler than multiple levels of REPLACE functions.
HTH,
DaveSlash
Hi, Dave!
Great idea, except that I think the poster wants the character(s) removed from the name, not replaced with a blank.
Kent
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Excellent point, Momi.
How about this:
replace(translate(avarchar
As long as you can ensure that there are no tildes in the string, then that should work.
-- DaveSlash
or more accurately:
replace(translate(avarchar
Hi Dave.
Just change all of the questionable characters to the same questionable character with translate, then delete it with a call to replace. No hunting for an unused character is necessary.
replace(translate(avarchar 25,'&','_% ', '&'),'&', '')
Speaking of questionable characters...
Well, never mind. :)
Kent
Just change all of the questionable characters to the same questionable character with translate, then delete it with a call to replace. No hunting for an unused character is necessary.
replace(translate(avarchar
Speaking of questionable characters...
Well, never mind. :)
Kent
> Speaking of questionable characters
Hey, I resemble that remark! :-) :-)
ASKER
please close this question
was your problem solved?
do you need to remove from a specific table or from all tables ?
basically this can be done using a single sql statement
update table_name
set column_name = case when posstr(column_name, '&') > 0 then replace(columns_name, '&', '')
when posstr(column_name, '_') > 0 then replace(columns_name, '_', '')
when posstr(column_name, '%') > 0 then replace(columns_name, '%', '')
end