DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    May 2005
    Location
    Trois-Rivières, QC, Canada
    Posts
    8

    Question Division by zero error handling

    Hi people,

    I need a little guidance here. To make a long story short, I have a string which would be "(123/0)+23". I need to put that string in a dynamic query. However, I want to avoid the division by zero error.

    if charindex('/0',@DynamicNumber) <> 0

    that won't work here, because I can have 0.002...

    Is there a way to do the update query: update #output set Column = @DynamicNumber

    and catch the error if I get a division by zero. In that case, I would just like to let the cell as a null value.

    Thanks for your help
    ---
    David Lemire, Consultant
    System Technologies for Industries Inc.

  2. #2
    Join Date
    Nov 2004
    Location
    Huddinge, Sweden
    Posts
    283
    Code:
    set arithabort off
    set arithignore on
    set ansi_warnings off
    select 17/0 as foo, 17/10 as bar
    arithabort and ansi_warnings off turn off the error
    arithignore on supressess the message

    Rune
    If you hit a brick wall, you didn't jump high enough!

  3. #3
    Join Date
    May 2005
    Location
    Trois-Rivières, QC, Canada
    Posts
    8

    Thanks

    Thanks Rune!

    That's exactly what I was looking for
    ---
    David Lemire, Consultant
    System Technologies for Industries Inc.

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
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links