Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 13th, 2008, 10:05 AM
toralf
Guest
 
Posts: n/a
Default matching criteris for a 10-digit number

Hello,

I'm wondering how I can test whether a field matches a 10-digit
integer within DB2.

--
MfG/Sincerely

Toralf Förster
pgp finger print: 7B1A 07F4 EC82 0F90 D4C2 8936 872A E508 7DB6 9DA3


  #2  
Old August 13th, 2008, 12:55 PM
Serge Rielau
Guest
 
Posts: n/a
Default Re: matching criteris for a 10-digit number

toralf wrote:
Quote:
Hello,
>
I'm wondering how I can test whether a field matches a 10-digit
integer within DB2.
>
Just add a check constraint to the column to force the range.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
  #3  
Old August 13th, 2008, 09:15 PM
Lennart
Guest
 
Posts: n/a
Default Re: matching criteris for a 10-digit number

On Aug 13, 1:51*pm, Serge Rielau <srie...@ca.ibm.comwrote:
Quote:
toralf wrote:
Quote:
Hello,
>
Quote:
I'm wondering how I can test whether a field matches a 10-digit
integer within DB2.
>
Just add a check constraint to the column to force the range.
>
Not sure I understand. Are you thinking in terms of

CHECK ( colx between '00' AND '99' )

? That wont work since (for example) '00' <= '4e' <= '99' or did you
have something else in mind?

/Lennart
  #4  
Old August 14th, 2008, 11:05 AM
Boris Stumm
Guest
 
Posts: n/a
Default Re: matching criteris for a 10-digit number

Lennart wrote:
Quote:
On Aug 13, 1:51Â*pm, Serge Rielau <srie...@ca.ibm.comwrote:
Quote:
>toralf wrote:
Quote:
Hello,
>>
Quote:
I'm wondering how I can test whether a field matches a 10-digit
integer within DB2.
>>
>Just add a check constraint to the column to force the range.
>>
>
Not sure I understand. Are you thinking in terms of
>
CHECK ( colx between '00' AND '99' )
These are chars, not integers. With integers, you would check
check (colx between 1000000000 and 9999999999). Then, DB2 enforces
that all values in this column have 10 digits (in decimal notation,
of course).
Quote:
? That wont work since (for example) '00' <= '4e' <= '99' or did you
have something else in mind?
I do not understand that. You want 10 digits in hex notation? I do not
know if DB2 allows hex notation of digits, if not, just convert do decimal
and put the decimal range.
  #5  
Old August 14th, 2008, 12:05 PM
toralf
Guest
 
Posts: n/a
Default Re: matching criteris for a 10-digit number

Boris Stumm wrote:
Quote:
check (colx between 1000000000 and 9999999999).
Hi,

this is what I was looking for - thx guys.

--
MfG/Sincerely

Toralf Förster
pgp finger print: 7B1A 07F4 EC82 0F90 D4C2 8936 872A E508 7DB6 9DA3


  #6  
Old August 14th, 2008, 03:15 PM
Lennart
Guest
 
Posts: n/a
Default Re: matching criteris for a 10-digit number

On Aug 14, 11:54*am, Boris Stumm <st...@informatik.uni-kl.dewrote:
Quote:
Lennart wrote:
Quote:
On Aug 13, 1:51*pm, Serge Rielau <srie...@ca.ibm.comwrote:
Quote:
toralf wrote:
Hello,
>
Quote:
Quote:
I'm wondering how I can test whether a field matches a 10-digit
integer within DB2.
>
Quote:
Quote:
Just add a check constraint to the column to force the range.
>
Quote:
Not sure I understand. Are you thinking in terms of
>
Quote:
CHECK ( colx between '00' AND '99' )
>
These are chars, not integers.
I'm well aware of that. The question seemed to obvious that I draw the
conclusion that the column was char(10). My bad

[...]
Quote:
>
I do not understand that. You want 10 digits in hex notation?
Not at all, 4e was an example of a string that is <= '99' and >= '00'
and not a valid integer (char representation of an integer).


/Lennart
 

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