Sie sind auf Seite 1von 2

FUNCTIONS:

These are the pre compiled programs which takes input called as arguments. These arguments
can be any data types and a function can return only one value which can be any data type
using the function name.

In oracle functions are of 2 types


(i) single row functions: these functions are executed once for a record. To compare
the output of a single row function use the where clause
(ii) multi row functions or group functions: these functions are executed once for a
group of records. To compare the output of multi row functions use the having
clause.

Single row functions

These are of 5 types


(a) numeric functions
(b) string functions
(c) date functions
(d) miscellaneous functions
(e) conversion functions

(a) Numeric functions

(i) abs(N1)
returns the magnitude of N1
eg abs(10)  10
abs(-10) 10
(ii) sign(N1)
returns +1(N1>0)
-1(N1<0)
0(N1=0)
eg sign(10) 1
sign(-10) -1
sign(0) 0
(iii) sqrt(N1)
returns the square root of N1
eg: sqrt(100) 10
(iv) power(N1,N2)
returns N1 ^ N2
eg: power(2,3)  8
power(3,2)  9
(v) mod(N1,N2)
returns remainder of N1/N2
eg: mod(10,2)  0
mod(10,3)  1
mod(2,10)  2
(vi) log(N1,N2)
returns logarithmic value of N2 to the base N1

eg: log(10,100)  2
log(2,16)  4
log(100,10)  0.5
(vii) ln(N1)
returns the logarithmic value of N1 to the base e(e=3.7182)
eg ln(20) = log(e,20)  3
(viii) exp(N1)
returns exponential of N1 (e ^ N1)
eg: exp(3)  e ^ 3  20

(ix) sin(N1)
(x) cos(N1)
(xi) tan(N1)
where N1 in Radians

returns N1 in radians

eg: sin(60*3.14/30)  0.8665


con(60*3.14/30)  0.5
tan(45*3.14/30)  1
(xii) round(N1,[N2])
returns N1 by rounding it to N2 position(default is 0)
eg round(12.456,2)  12.46
round(12.456,1)  12.5
round(12.456,0) or round(12.456)  12 (because default of N2 is 0)
round(12.456,-1)  10
round(156.345,-2)  200
note: round returns the nearest multiple of 10 ^ (-N)

(xiii) trunc(N1,[N2])
return N1 by truncating it to N2 position (default is 0)
eg: trunc(12.456,2)  12.45
trunc(12.456,1)  12.4
trunc(12.456,0) or trunc(12.456)  12
trunc(12.456,-1)  10
trunc(156.345,-2)  100
(xiv) ceil(N1)
returns the next integer value >=N1
eg:
ceil(12.456)  13
ceil(12.00001)  13
ceil(12)  12
(xv) floor(N1)
returns the previous integer value <= N1
eg:
floor(12.456)  12
floor(12.99999)  12
floor(12)  12

Das könnte Ihnen auch gefallen