matching criteris for a 10-digit number

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • toralf

    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


  • Serge Rielau

    #2
    Re: matching criteris for a 10-digit number

    toralf wrote:
    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

    Comment

    • Lennart

      #3
      Re: matching criteris for a 10-digit number

      On Aug 13, 1:51 pm, Serge Rielau <srie...@ca.ibm .comwrote:
      toralf wrote:
      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.
      >
      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

      Comment

      • Boris Stumm

        #4
        Re: matching criteris for a 10-digit number

        Lennart wrote:
        On Aug 13, 1:51 pm, Serge Rielau <srie...@ca.ibm .comwrote:
        >toralf wrote:
        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.
        >>
        >
        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).
        ? 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.

        Comment

        • toralf

          #5
          Re: matching criteris for a 10-digit number

          Boris Stumm wrote:
          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


          Comment

          • Lennart

            #6
            Re: matching criteris for a 10-digit number

            On Aug 14, 11:54 am, Boris Stumm <st...@informat ik.uni-kl.dewrote:
            Lennart wrote:
            On Aug 13, 1:51 pm, Serge Rielau <srie...@ca.ibm .comwrote:
            toralf wrote:
            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.
            >
            Not sure I understand. Are you thinking in terms of
            >
            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

            [...]
            >
            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

            Comment

            Working...