Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 11th, 2006, 09:45 AM
kanpeter@graduate.hku.hk
Guest
 
Posts: n/a
Default Check varchar field numeric using SQL

Hi,

How can I check if all bytes in a varchar field is all numeric using
SQL ?

-- peter

  #2  
Old August 11th, 2006, 12:15 PM
Knut Stolze
Guest
 
Posts: n/a
Default Re: Check varchar field numeric using SQL

kanpeter@graduate.hku.hk wrote:
Quote:
Hi,
>
How can I check if all bytes in a varchar field is all numeric using
SQL ?
You could:
(1) use a loop and check each character manually
(note: signs and exponents for floating point numbers)
(2) try to convert the value and intercept exceptions for non-digits
(3) use regular expression matching:
http://www.ibm.com/developerworks/db...301stolze.html

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
  #3  
Old August 11th, 2006, 02:15 PM
Brian Tkatch
Guest
 
Posts: n/a
Default Re: Check varchar field numeric using SQL


kanpeter@graduate.hku.hk wrote:
Quote:
Hi,
>
How can I check if all bytes in a varchar field is all numeric using
SQL ?
>
-- peter
WHERE TRANSLATE(<field>, '', '1234567890') = '' AND <field<''

B.

  #4  
Old August 12th, 2006, 03:35 AM
Tonkuma
Guest
 
Posts: n/a
Default Re: Check varchar field numeric using SQL


WHERE TRANSLATE(<field>, '*', ' 1234567890') = ''
If there is a possibility of "length(<field>) = 0", you had better to
use Brian's way.

  #5  
Old August 14th, 2006, 02:15 PM
Brian Tkatch
Guest
 
Posts: n/a
Default Re: Check varchar field numeric using SQL


Tonkuma wrote:
Quote:
WHERE TRANSLATE(<field>, '*', ' 1234567890') = ''
If there is a possibility of "length(<field>) = 0", you had better to
use Brian's way.
Thanx Tonkuma.

When i replied before i was thinking "How would Tonkuma do it?".

In my mind, TRANSLATE is your function. :)

B.

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles