Call (800) 766-1884 for Oracle support & training
Free Oracle Tips


Oracle Consulting Support
Oracle Upgrades
Use New Oracle Features
Oracle Replication Support
Oracle Training
Remote Oracle DBA
System Documentation
Oracle Tips
Oracle Performance
 

Free Oracle Tips


 

HTML Text

BC Oracle tuning

Oracle training

Oracle support

Remote Oracle

 

 

   
 

Numeric Functions
Oracle Tips by Burleson
 

The following functions all accept numeric values as parameters and return numeric values. Each of the functions listed in this section is accurate to 38 significant digits.

abs()

The abs() function accepts a single number as a parameter and returns the absolute value of that number. For example,

abs (-9.37)

returns

9.37

mod()

The mod() function accepts two numbers as parameters, x and y, and returns the remainder of x divided by y. For instance, calling the function to get the remainder of 5 divided by 2,

mod (5, 2)

returns

1

If y is zero, the function returns x. For instance,

mod (5, 0)

returns

5

power()

The power() function accepts two numbers as parameters, x and y, and returns the value of x raised to the power of y. For instance, calling the function to get the value of 10 raised to the 6th power,

power (10, 6)

returns

1000000

If the value of x is negative, the value of y must be an integer. For instance,

power (-3.54, 2)

returns

12.5316

round()

The round() function accepts a single number, x, as a parameter and rounds that number to the nearest integer value. For instance, calling the function with a value of 15.37,

round (15.37)

returns

15

The function can also take an integer parameter, y, following the number parameter. This parameter tells the function how many significant digits should be left in place. Using the same value as the previous example while passing 1 for the y parameter,

round (15.37, 1)

returns

15.4

If y is a negative value, the function rounds backwards from the decimal. For example,

round (153.17, -1)

returns

150

which has been rounded at the ones position in the final value.

The function can be called with only one parameter. In this case, y defaults to 0, and the function returns an integer value.

sqrt()

The sqrt() function accepts a single number as a parameter and returns the square root of that number. For instance, passing 4 to the function,

sqrt (4)

returns

2

This function can’t accept a negative value as a parameter, but the function can return a decimal value. For example,

sqrt (5.25)

returns

2.29128785

trunc()

The trunc() function accepts a single number, x, as a parameter and returns that number truncated to 0 decimal places. For instance,

trunc (15.37)

returns

15

The function’s second parameter, y, tells the function how many digits of the number should be left intact. This second parameter defaults to 0 and must be an integer value. Using the same value as the previous example, but passing 1 for y,

trunc (15.37, 1)

returns

15.3

             
This is an excerpt from the book "High Performance Oracle Database Automation" by Jonathan Ingram and Donald K. Burleson, Series Editor.

  
 

Oracle performance tuning software 
 
 
 
 

Oracle performance tuning book

 

 
 
 
Oracle performance Tuning 10g reference poster
 
 
 
Oracle training in Linux commands
 
Oracle training Excel
 
Oracle training & performance tuning books
 

 

   

Copyright © 1996 -  2014 by Burleson. All rights reserved.

Oracle® is the registered trademark of Oracle Corporation. 

Hit Counter