Results 1 to 9 of 9
  1. #1
    Join Date
    May 2008
    Posts
    35

    Unanswered: Modulus Operator Help

    I'm trying to do a modulus on DB2 but it fails % is not a valid

    and (COLA/COLB)%10 != 0

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Mod(cola/colb, 10)

  3. #3
    Join Date
    May 2008
    Posts
    35
    It says no aothorized routine named Mod of type function having compatible arguments were found.

  4. #4
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    What are the data types of cola and colb?

    What platform and DB2 version/release are you using?

    Here is an example on DB2 9.7 for Windows.
    Code:
    ------------------------------ Commands Entered ------------------------------
    SELECT cola , colb
         , cola / colb        division
         , MOD(cola/colb, 10) modulus
      FROM(VALUES (191, 13) ) r(cola, colb);
    ------------------------------------------------------------------------------
    
    COLA        COLB        DIVISION    MODULUS    
    ----------- ----------- ----------- -----------
            191          13          14           4
    
      1 record(s) selected.

  5. #5
    Join Date
    May 2008
    Posts
    35
    Both columns are decimal

  6. #6
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    DB2 9.7.1 Express-C on Windows.
    Code:
    ------------------------------ Commands Entered ------------------------------
    SELECT cola , colb
         , cola / colb        division
         , MOD(cola/colb, 10) modulus
      FROM(VALUES (191.9, 13.1) ) r(cola, colb);
    ------------------------------------------------------------------------------
    
    COLA   COLB  DIVISION                          MODULUS    
    ------ ----- --------------------------------- -----------
     191.9  13.1    14.648854961832061068702290076           4
    
      1 record(s) selected.
    Last edited by tonkuma; 12-16-09 at 04:04.

  7. #7
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    It says no aothorized routine named Mod of type function having compatible arguments were found.
    Please give me your query, results and error messages(full text you received).

  8. #8
    Join Date
    May 2008
    Posts
    35
    SELECT COLA,
    COLB,
    MOD(COLA/ COLB, 10)
    FROM TABLE
    WITH ur

  9. #9
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    And the exact error message (incl. message number)?
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •