|
-
Dec 27th, 2005, 12:51 PM
#1
Thread Starter
Fanatic Member
Finding Non Numeric Fields in Oracle
In vb and i think even in MS SQL server there is a ISNumeric function built in. I know there's no function like that in Oracle (9i), but i was thinking that there might be a logical way to determine if a field is Numeric or Not. Unfortunetly i can't use a stored procedure to do this either. So i'd have to do it in the sql statement itself.
Does anyone have an idea on how to do this?
Select Field1 from table_name
where field1 is NOT numeric
Thanks
Andy
Using VB6 or VB.net 2008 with .net 3.5
"Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad
-
Dec 27th, 2005, 01:02 PM
#2
Re: Finding Non Numeric Fields in Oracle
Well you could use views like all_tab_columns
Check the data_type column in all_tab_columns.
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Dec 27th, 2005, 01:40 PM
#3
Thread Starter
Fanatic Member
Re: Finding Non Numeric Fields in Oracle
sorry i'm not trying to find the data type i'm trying to determine whether or not a value is numeric. For instance.
Field1
-----
aasdf
sdifiue123
32fafk
12314
asdfkj3
i need a way to filter out the row (12314) and return the rest.
Using VB6 or VB.net 2008 with .net 3.5
"Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad
-
Dec 27th, 2005, 01:48 PM
#4
Re: Finding Non Numeric Fields in Oracle
try this pl / sql block.
Code:
begin
......
BEGIN
l_test_number := l_string_that_might_hold_a_number;
.... code that should run when it is in fact a number......
EXCEPTION
WHEN OTHERS
then
..... code that should run when it is in fact NOT a number.....
END;
.......
end;
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Dec 27th, 2005, 01:52 PM
#5
Thread Starter
Fanatic Member
Re: Finding Non Numeric Fields in Oracle
I saw this on another website, but right now i can't use a stored procedure. So how could i use it in a vb program?
Using VB6 or VB.net 2008 with .net 3.5
"Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad
-
Dec 27th, 2005, 01:54 PM
#6
Re: Finding Non Numeric Fields in Oracle
I made an oracle function out of it.
Code:
create or replace function isanumber(x varchar2) return boolean
is
begin
declare l_test_number number;
BEGIN
l_test_number := x;
return true;
EXCEPTION
WHEN OTHERS THEN
return false;
END;
end;
/
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Dec 27th, 2005, 01:59 PM
#7
Re: Finding Non Numeric Fields in Oracle
What about a simple IsNumeric test?
VB Code:
If Not IsNumeric(field1) then
Do what you need to do with the record
else
Throw the record out or do something different with it
end if
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Dec 27th, 2005, 02:35 PM
#8
Thread Starter
Fanatic Member
Re: Finding Non Numeric Fields in Oracle
i think that is what i'm gonna do. I'd like to use the function that abhijit suggested, but i doubt i have permission to create it. I was hoping there would be just a simple thing to add to my select statement, but i guess not. And i thought that i had seen a function before that would allow me to do it but i can't find it anywhere.
Using VB6 or VB.net 2008 with .net 3.5
"Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad
-
Dec 27th, 2005, 02:37 PM
#9
Re: Finding Non Numeric Fields in Oracle
space_monkey hang on for a moment before you create the function. i just tested it and its giving me a problem. so let me fix it and then you can have the function.
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Dec 27th, 2005, 04:48 PM
#10
Re: Finding Non Numeric Fields in Oracle
hey I fixed this function. the reason it was throwing an error is that boolean is only available in pl/sql and not in sql. here is my fix.
Code:
create or replace function isanumber(x varchar2) return varchar2
is
begin
declare l_test_number number;
BEGIN
l_test_number := x;
return 'true';
EXCEPTION
WHEN OTHERS THEN
return 'false';
END;
end;
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Dec 27th, 2005, 05:17 PM
#11
Thread Starter
Fanatic Member
Re: Finding Non Numeric Fields in Oracle
Thanks abhijit, I'll try it out.
Using VB6 or VB.net 2008 with .net 3.5
"Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|