|
|
|
|
|
|
|
|
|
|
Re: how to remove special characters from oracle forms fields? [message #606695 is a reply to message #606693] |
Tue, 28 January 2014 04:06 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/dbb2b1195a98d84e36dd1b3b1d6ae655?s=64&d=mm&r=g) |
jineesh
Messages: 14 Registered: January 2014
|
Junior Member |
|
|
I tried like this
Select Col1
from (select regexp_substr(:p_Tel,'[^,]+', 1,Level) col1 from dual
connect by regexp_substr(:p_Tel,'[^,]+', 1,Level) Is not Null);
But, regexp_substr not supporting on Oracle forms 6i.
Whit this query am getting value on sql.
[Updated on: Tue, 28 January 2014 04:08] Report message to a moderator
|
|
|
|
|
|
|
|
Re: how to remove special characters from oracle forms fields? [message #606706 is a reply to message #606705] |
Tue, 28 January 2014 04:45 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Forms 6i doesn't pre-dates regexp_replace so doesn't recognize it, that's what you get for running an old unsurported version of forms (time to upgrade to 11g).
You can either:
a) create a db function that does the regexp_replace and call that from the form.
b) make do with normal replace instead.
|
|
|
|
Re: how to remove special characters from oracle forms fields? [message #606733 is a reply to message #606710] |
Tue, 28 January 2014 07:15 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/1229663c86eb1a441385fe710cd9116e?s=64&d=mm&r=g) |
mughals_king
Messages: 392 Registered: January 2012 Location: pakistan
|
Senior Member |
|
|
Yes @cookiemonster is right try to create DB function i have acomplished this task many time ago i would give you some examples may be could help you
SQL> connect sys/manager@arla as sysdba
Connected.
SQL> CREATE OR REPLACE FUNCTION no_spec(p_row VARCHAR2) RETURN VARCHAR2 IS
2 v_result VARCHAR2(4000) := '';
3 BEGIN
4 FOR i IN 1..LENGTH(p_row) LOOP
5 IF SUBSTR(p_row,i,1) >= 48 AND SUBSTR(p_row,i,1) <= 122 THEN
6 v_result := SUBSTR(p_row,i,1);
7 END IF;
8 END LOOP;
9
10 return v_result;
11
12 END no_spec;
13 /
Function created.
-----------
Now use it
SELECT no_spec(my_column) from my_table;
You could just use the TRANSLATE function:
PROCEDURE no_special_chars
IS
ok_characters VARCHAR2(1000) :=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012456789., ';
-- add to 'ok_characters' all the characters that are ok to keep...any characters NOT in this
-- list will be removed through the use of the TRANSLATE function.
BEGIN
UPDATE my_table
SET column_name = TRANSLATE( column_name, ok_characters, ok_characters);
END;
FUNCTION no_special_chars( p_input VARCHAR2 )
RETURN VARCHAR2
IS
ok_characters VARCHAR2(1000) :=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012456789., ';
return_string VARCHAR2(4000);
BEGIN
SELECT TRANSLATE( p_input, ok_characters, ok_characters) INTO return_string FROM dual;
RETURN ( return_string );
END;
FUNCTION no_special_chars( p_input VARCHAR2 )
RETURN VARCHAR2
IS
ok_characters VARCHAR2(1000) :=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012456789., ';
return_string VARCHAR2(4000);
BEGIN
SELECT TRANSLATE( p_input, TRANSLATE( p_input, ok_characters, ok_characters), ok_characters )
INTO return_string FROM dual;
RETURN ( return_string );
END;
Then you could:
SELECT no_special_chars( your_column) FROM your_table;
DECLARE
str VARCHAR2 (4000) := 'dd34g67,8;4,jr[7]9[5=-\],o;0';
nbr VARCHAR2 (4000);
n VARCHAR2 (1);
BEGIN
FOR i IN 1 .. LENGTH (str)
LOOP
n := SUBSTR (str, i, 1);
IF n IN ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')
THEN
nbr := nbr || n;
END IF;
END LOOP;
dbms_output.put_line (nbr);
END;
/
And this was my target when i was acomplished this task i don't exactly remember
Try this
Create this function by running this script:
-------
CREATE FUNCTION [DBO].[STRIPNONALPHACHARACTERS](@INPUT VARCHAR(255))
RETURNS VARCHAR(255)
AS
BEGIN
WHILE PATINDEX('%[^A-Z]%', @INPUT) > 0
SET @INPUT = STUFF(@INPUT, PATINDEX('%[^A-Z]%', @INPUT), 1, '')
RETURN @INPUT
END
--Check it with these
--Select dbo.StripNonAlphaCharacters('abc1234def5678ghi90jkl')
--Select dbo.StripNonAlphaCharacters('1Smith*45')
---------
Then run this script to create the tables, populate, and test:
---------
IF OBJECT_ID('#table1', 'U') IS NOT NULL
DROP TABLE #table1
GO
CREATE TABLE dbo.#table1
(
model char(10) NULL
)
GO
IF OBJECT_ID('dbo.#table12', 'U') IS NOT NULL
DROP TABLE dbo.#table2
GO
CREATE TABLE dbo.#table2
(
model char(10) NULL
)
GO
Insert into #table1 (model)
select 'ABC*1234'
union
select ('DEF*1234')
union all
select ('GHI*1234')
union all
select ('JKL*56789')
union all
select ('JKL*56789')
union all
select ('JKL*56789')
Insert into #table2 (model)
select ('ABC')
union all
select ('DEF')
union all
select ('GHI')
union all
select ('JKL')
union all
select ('JKL')
union all
select ('JKL')
--See that it does not match
select *
from #table1 t1, #table2 t2
where t1.model = t2.model
--See that it does match with function
select *
from #table1 t1, #table2 t2
where (dbo.StripNonAlphaCharacters(t1.model)) = t2.model
---------
Hope something you will get from this.
Regard
Mughal
|
|
|
|
|
|
|
|