Solved

POWER function

Posted on 2001-07-26
8
355 Views
Last Modified: 2007-12-19
I am trying to execute the following and I'm receiving an error:

SELECT POWER(-192427.50013516, -.33333 )

The error is "A domain error occurred"

Anybody know a way around this? I know that usually when you get this error, it means that the arguments are outside the valid range, but, I can't find what the valid range might be.
0
Comment
Question by:songstre
  • 4
  • 4
8 Comments
 
LVL 30

Expert Comment

by:SteveGTR
ID: 6321784
Domain errors occur when the value provided in the mathematical function is not a valid value.

SET ARITHIGNORE ON, which causes no warning message to be displayed. Both the SET ARITHABORT and SET ANSI_WARNINGS settings override the SET ARITHIGNORE setting.
0
 
LVL 1

Author Comment

by:songstre
ID: 6321822
OK, but I still don't get a value. If the values provided are outside the valid values of the function, then what are the valid values of the function? Then I can check them and provide defaults.
0
 
LVL 1

Author Comment

by:songstre
ID: 6321839
OK, but I still don't get a value. If the values provided are outside the valid values of the function, then what are the valid values of the function? Then I can check them and provide defaults.
0
 
LVL 30

Expert Comment

by:SteveGTR
ID: 6321961
I think that you run into problems when you try to raise a negative number to a negative number less then zero:

power(-1, -.1)

You could check to make sure that the second number is not less than zero when the first number is negative. Or you could just treat these errors as zero's. I'm not sure if your application permits this or not.

SET ARITHIGNORE ON

select isnull(power(-.1, .1), 0)
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 1

Author Comment

by:songstre
ID: 6322029
I tried using isnull. It's not returning null. There's just nothing. Also, power(-1, .1) doesn't work either and the second arg is not negative.
0
 
LVL 30

Expert Comment

by:SteveGTR
ID: 6322506
Sorry for the typo... So this doesn't print zero?

SET ARITHIGNORE ON

select isnull(power(-.1, -.1), 0)

Is that what you are saying? I'm running SQL 7 here --- what are you using?

0
 
LVL 1

Author Comment

by:songstre
ID: 6322610
SQL 2000

select isnull(power(-.1, -.1), 0)

gives me nothing, not 0.

And I found out that it is not mathematically possible. If you do the above calculation in Calculator, you get 'Invalid Input for function.'

I'll give you the points for trying, though.
0
 
LVL 30

Accepted Solution

by:
SteveGTR earned 50 total points
ID: 6322829
>>And I found out that it is not mathematically possible.
>>If you do the above calculation in Calculator, uyou >>get 'Invalid Input for function.'

I believe my first message stated this fact...

"Domain errors occur when the value provided in the mathematical function is not a valid value."

That's odd that SQL doesn't print anything. Well thanks :)
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now