Professional Web Applications Themes

??? Domain Error Occurred ??? - Microsoft SQL / MS SQL Server

I am running a query that takes the cross product of a table against itself and uses some trigonometry functions to determine the distance between all the values. The cross product works but when I introduce the trig function only part of the result set comes back. No error is reported only a very non-descriptive message: A domain error occurred. Has anyone ever seen this before? I have not been able to find any information on it web. Here is a query that tes the error I am getting using the Northwind database: Select o1.OrderID, o2.OrderID, foo = ACOS( COS(o1.OrderID) ...

  1. #1

    Default ??? Domain Error Occurred ???

    I am running a query that takes the cross product of a
    table against itself and uses some trigonometry functions
    to determine the distance between all the values. The
    cross product works but when I introduce the trig
    function only part of the result set comes back. No
    error is reported only a very non-descriptive message:

    A domain error occurred.

    Has anyone ever seen this before? I have not been able
    to find any information on it web.

    Here is a query that tes the error I am getting
    using the Northwind database:

    Select
    o1.OrderID,
    o2.OrderID,
    foo =
    ACOS(
    COS(o1.OrderID) * COS(o2.OrderID) +
    SIN(o1.OrderID) * SIN(o2.OrderID)
    )
    From
    Orders o1 Cross Join Orders o2

    Thanks for taking a look. -Scott

    Scott Guest

  2. #2

    Default Re: ??? Domain Error Occurred ???

    I get the same thing on 2000 SP3 (760). I'll see what I can do to report
    it...


    "Scott Archibald" <com> wrote in message
    news:018301c3680c$d4037b00$gbl... 


    Aaron Guest

  3. #3

    Default Re: ??? Domain Error Occurred ???

    Methinks there are combinations of (o1.OrderID, o2.OrderID) where the argument of ACOS is beyond +/- 1.0. How about runnin gthe query without ACOS and just compute the remainder. List those where the absolute value is > 1.0.

    --
    Tom
    --------------------------------------------
    Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
    SQL Server MVP
    Columnist, SQL Server Professional
    Toronto, ON Canada
    www.pinnaclepublishing.com.sql
    ..

    "Scott Archibald" <com> wrote in message news:00f801c36810$4241a670$gbl...
    It seems the error is related to the ACOS function. I
    can't te the error without ACOS but the error
    always occurs regardless of how simple the function is if
    the ACOS function exists.

    -Scott

     
    can do to report [/ref]
    functions 
    >
    >
    >.
    >[/ref]
    Tom Guest

  4. #4

    Default Re: ??? Domain Error Occurred ???

    Precisely. Trig functions return float, with the infamous
    rounding errors. These rounding errors result in values
    outside the +- 1 range. Try:

    Select
    o1.OrderID,
    o2.OrderID,
    foo = COS(o1.OrderID) * COS(o2.OrderID) + SIN
    (o1.OrderID) * SIN(o2.OrderID)

    From
    Orders o1 Cross Join Orders o2
    where COS(o1.OrderID) * COS(o2.OrderID) + SIN(o1.OrderID)
    * SIN(o2.OrderID) > 1

    and you'll see your offending rows. You can fix it by
    CASTing the value to, e.g., numeric(9,8), before you apply
    the ACOS function.

    Select
    o1.OrderID,
    o2.OrderID,
    foo =
    ACOS(
    CAST(COS(o1.OrderID) * COS(o2.OrderID) +
    SIN(o1.OrderID) * SIN(o2.OrderID) AS numeric(9,8))
    )
    From
    Orders o1 Cross Join Orders o2

    HTH
    Vern 
    o2.OrderID) where the argument of ACOS is beyond +/- 1.0.
    How about runnin gthe query without ACOS and just compute
    the remainder. List those where the absolute value is >
    1.0. 
    news:00f801c36810$4241a670$gbl... 
    if [/ref]
    I [/ref][/ref]
    a [/ref]
    > functions [/ref][/ref]
    The [/ref][/ref]
    message: [/ref][/ref]
    able [/ref][/ref]
    getting 
    > >
    > >
    > >.
    > >[/ref][/ref]
    Vern Guest

Similar Threads

  1. Replies: 0
    Last Post: September 14th, 12:04 PM
  2. Replies: 0
    Last Post: November 12th, 03:43 PM
  3. Replies: 0
    Last Post: September 25th, 03:23 AM
  4. Replies: 1
    Last Post: August 7th, 07:13 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139