/ Published in: SQL
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* Strip(remove) special character(s) from a string. Parameters -1-: String to process -2-: Special character to strip Note: If second parameter is null then the following list is used: <tab>, <single quote>, <double quote>, <\>, <|>, <`>, <~>, <^> */ FUNCTION strip_spc_character ( in_string IN varchar2, in_chars IN varchar2 DEFAULT NULL ) RETURN varchar2 IS tab CHAR( 1 ) := chr(9); double_quote CHAR( 1 ) := chr(34); single_quote CHAR( 1 ) := chr(39); mask varchar2( 80 ) := '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; v_special_chars varchar2( 80 ) := '`~^\|'||double_quote||single_quote||tab; BEGIN IF in_chars IS NOT NULL THEN v_special_chars := in_chars; END IF; RETURN translate( in_string, mask || v_special_chars, mask ); exception WHEN others THEN RETURN in_string; END strip_spc_character;