You are on page 1of 27

Single-Row Functions

Single-row functions return a single result row for every row of a queried table or view. These functions can appear in select lists, WHERE clauses, ST RT W!TH and "#$$E"T %& clauses, and H '!$( clauses.

Number Functions
$u)ber functions accept nu)eric input and return nu)eric values. *ost of these functions return values that are accurate to +, deci)al digits. The nu)ber functions available in #racle areABS ACOS ASIN ATAN ATAN2 BITAND CEIL COS COSH EXP FLOOR LN LOG MOD POWER ROUND (number) SIGN SIN SINH SQRT TAN TANH TRUNC (number) ABS
%S

returns the absolute value of n.

The following e.a)ple returns the absolute value of -,/SE0E"T %S1-,/2 3 bsolute3 4R#* 56 07 Ab !"u#e $$$$$$$$$$ %& ACOS
"#S returns the arc cosine of n. !nputs are in the range of -8 to 8, and outputs are in the range of 9 to pi and are e.pressed in radians.

The following e.a)ple returns the arc cosine of .+SE0E"T "#S1.+23 rc:"osine3 4R#* 56 07 Ar'(C! )ne $$$$$$$$$$ *+2,,*-.,& Si)ilar to "#S, you have S!$ 1 rc Sine2, T $ 1 rc Tangent2 functions.

CIEL Returns the lowest integer above the given nu)ber. E.a)pleThe following function return the lowest integer above +.;<=7 select ciel1+.;<=2 >"iel? fro) dual7 C)e" $$$$$$$$$ / FLOOR Returns the highest integer below the given nu)ber. E.a)pleThe following function return the highest integer below +.;<=7 select floor1+.;<=2 >4loor? fro) dual7 F"!!r $$$$$$$$$$$$ . COS Returns the cosine of an angle 1in radians2. E.a)pleThe following e.a)ple returns the "#S!$E angle of =9 radians. e"e'# SIN Returns the Sine of an angle 1in radians2. E.a)pleThe following e.a)ple returns the S!$E angle of =9 radians. '! (,-) 0C! )ne1 2r!m 3u4"5

e"e'#

SIN(,-) 0S)ne1 2r!m 3u4"5

TAN Returns the Tangent of an angle 1in radians2. E.a)pleThe following e.a)ple returns the tangent angle of =9 radians. e"e'# T4n(,-) 0T4n6en#1 2r!m 3u4"5

Si)ilar to S!$, "#S, T $ functions hyperbolic functions S!$H, "#SH, T $H are also available in oracle. MOD Returns the re)ainder after dividing ) with n. E.a)ple The following e.a)ple returns the re)ainder after dividing +9 by ;. Se"e'# m!3(.-7/) 0MOD1 2r!m 3u4"5 MOD $$$$$$$$$ 2 PO ER Returns the power of ), raised to n. E.a)ple The following e.a)ple returns the @ raised to the power of +. e"e'# 8!9er(27.) 0P!9er1 2r!m 3u4"5

POWER $$$$$$$$$ % E!P

Returns the e raised to the power of n. E.a)ple The following e.a)ple returns the e raised to power of @. e"e'# e:8(2) 0e r4) e3 #! 21 2r!m 3u4"5 E R !SE5 T# @ -------------

LN Returns natural logarith) of n. E.a)ple The following e.a)ple returns the natural logarith) of @. e"e'# "n(2) 2r!m 3u4"5 0$ ------------

LO" Returns the logarith), base ), of n.

E.a)ple The following e.a)ple returns the log of 899. e"e'# "!6(*-7*--) 2r!m 3u4"5 LOG $$$$$$$$$ 2 RO#ND

Returns a deci)al nu)ber rounded of to a given deci)al positions. E.a)ple The following e.a)ple returns the no. +.;</+ rounded to @ deci)als.

e"e'# r!un3(.+/;&.72) 0R!un31 2r!m 3u4"5 R!un3 $$$$$$$$$$$$ .+/, TR#NC

Returns a deci)al nu)ber Truncated to a given deci)al positions. E.a)ple The following e.a)ple returns the no. +.;</+ truncated to @ deci)als. e"e'# r!un3(.+/;&.72) 0R!un31 2r!m 3u4"5 R!un3 $$$$$$$$$$$$ .+/; S$RT Returns the square root of a given nu)ber. E.a)ple The following e.a)ple returns the square root of 8=. e"e'# SQRT $$$$$$$$$ / <r#(*,) 2r!m 3u4"5

C%&r&cter Functions

"haracter functions operate on values of dataype "H R or ' R"H R. LO ER Returns a given string in lower case. e"e'# LOWER(=SAMI>) 2r!m 3u4"5 LOWER $$$$$$$$$$$$$ 4m) #PPER Returns a given string in 6AAER case. e"e'# UPPER(=S4m)>) 2r!m 3u4"5 UPPER $$$$$$$$$$$$$$$$$$ SAMI

INITCAP Returns a given string with !nitial letter in capital. e"e'# INITCAP(=m!?4mme3 INITCAP $$$$$$$$$$$$$$$$$$ M!?4mme3 S4m) 4m)>) 2r!m 3u4"5

LEN"T' Returns the length of a given string. e"e'# "en6#?(=m!?4mme3 LENGTH $$$$$$$$$$$$ *. 4m)>) 2r!m 3u4"5

S#BSTR Returns a substring fro) a given string. Starting fro) position p to n characters. 4or e.a)ple the following query returns >sa)? fro) the string >)oha))ed sa)i?. e"e'# Sub #r $$$$$$$$ 4m INSTR Tests whether a given character occurs in the given string or not. !f the character occurs in the string then returns the first position of its occurrence otherwise returns 9. E.a)ple The following query tests whether the character >a? occurs in string >)oha))ed sa)i? e"e'# )n #r(@m!?4mme3 !$STR -------; REPLACE Replaces a given set of characters in a string with another set of characters. E.a)ple The following query replaces >)ohd? with >)oha))ed? . e"e'# re8"4'e(@4") m!?3 A?4n@7@m!?3@7@m!?4mme3@) 2r!m 3u4"5 REPLACE $$$$$$$$$ 4") m!?4mme3 A?4n 4m)@7@4@) 2r!m 3u4"5 ub #r(@m!?4mme3 4m)@7*-7.) 2r!m 3u4"5

TRANSLATE

This function is used to encrypt characters. 4or e.a)ple you can use this function to replace characters in a given string with your coded characters. E.a)ple The following query replaces characters with %, % with ", " with 5, 5 with E,...B with , and a with b,b with c,c with d, d with e ....C with a. e"e'# #r4n "4#e(@)n#er24'e@7@ABCDEFGHIBCLMNOPQRSTUDWXEF4b'3e26?)G A"mn!8<r #uH9:IJ@7@BCDEFGHIBCLMNOPQRSTUDWXEFAb'3e26?)GA"mn! 8<r #uH9:IJ4@) 0En'rI8#1 2r!m 3u4"5

En'rI8# $$$$$$$$$$$ G!u2 6b32 SO#NDE! This function is used to checD pronounciation rather than e.act characters. 4or e.a)ple )any people write na)es as >s)ith? or >s)yth? or >s)ythe? but they are pronounced as s)ith only. E.a)ple The following e.a)ple co)pare those na)es which are spelled differently but are pronouced as >s)ith?. Se"e'# en4me 2r!m em8 9?ere ENAME $$$$$$$$$ Sm)#? SmI#? SmI#?e !un3e:(en4me)K !un3e:(@ m)#?@)5

RPAD Right pads a given string with a given character to n nu)ber of characters. E.a)ple

The following query rights pad ena)e with EFE until it beco)es 89 characters. e"e'# r843(en4me7@L@7*-) 2r!m em85 En4me $$$$$$$$$$ Sm)#?LLLLL B!?nLLLLLL M!?4mme3LL S4m)LLLLLL LPAD 0eft pads a given string with a given character upto n nu)ber of characters. E.a)ple The following query left pads ena)e with EFE until it beco)es 89 characters. e"e'# "843(en4me7@L@7*-) 2r!m em85 En4me $$$$$$$$$$ LLLLLSm)#? LLLLLLB!?n LLM!?4mme3 LLLLLLS4m) LTRIM Tri)s blanD spaces fro) a given string fro) left. E.a)ple The following query returns string > e"e'# "#r)m(@ 0tri) -------------!nterface RTRIM Tri)s blanD spaces fro) a given string fro) Right. !nterface > left tri))ed. @) 2r!m 3u4"5

In#er24'e

E.a)ple The following query returns string > e"e'# r#r)m(@ R#r)m $$$$$$$$$$$$ In#er24'e TRIM Tri)s a given character fro) left or right or both fro) a given string. E.a)ple The following query re)oves Cero fro) left and right of a given string. Se"e'# #r)m(- 2r!m @----.//.;--@) 2r!m 3u4"5 Tr)m $$$$$$$$$$ .//.; CONCAT "o)bines a given string with another string. E.a)ple The following Guery co)bines ena)e with literal string > is a > and Hobid. Se"e'# '!n'4#('!n'4#(en4me7@ ) C!n'4# $$$$$$$$$$$$$$$$ Sm)#? ) 4 '"erA B!?n ) 4 M4n46er S4m) ) 4 G+M4n46er 4 @)7G!b) 2r!m em85 !nterface > right tri))ed. @) 2r!m 3u4"5

In#er24'e

Miscell&neous Single Row Functions

COALESCE "oalesce function returns the first not null value in the e.pression list. E.a)ple. The following query returns salaryIco))ision, if co))ission is null then returns salary, if salary is also null then returns 8999.

e"e'# em8n!7en4me7 4"4rI7'!mm7'!4"e 'e( 4"4rIM'!mm7 4"4rI7*---) 0Ne# S4"1 2r!m em85

ENAME $$$$$ SMITH SAMI SCOTT RADI DECODE

SALARE $$$$$$ *--.---

COMM NET SAL $$$$ $$$$$$$ *-- **-.--*--2-- *---

5E"#5E1e.pr, searchvalue8, result8,searchvalue@,result@,..., defaultvalue2 5ecode functions co)pares an e.pr with search value one by one. !f the e.pr does not )atch any of the search value then returns the default value. !f the default value is o)itted then returns null. E.a)ple The following query returns the depart)ent na)es according the deptno. !f the deptno does not )atch any of the search value then returns >6nDnown 5epart)ent? e"e'# 3e'!3e(3e8#n!7*-7@S4"e @72-7@A''!un# 7.-7@Pr!3u'#)!n7 /-7@RND@7@UnAn!9n De8#@) A DEPTNAME $$$$$$$$$$ S4"e A''!un# UnAn!9n De8#+ A''!un# De8#N4me 2r!m em85

Pr!3u'#)!n S4"e RND UnAn!9n De8#+

"REATEST (RE TEST1e.pr8, e.pr@, e.pr+,e.pr;...2 Returns the greatest e.pr fro) a e.pr list. E.a)ple e"e'# 6re4#e #(*-72-7;-72-7.-) 2r!m 3u4"5 GREATEST $$$$$$$$ ;-

e"e'# 6re4#e #(@SAMI@7@SCOTT@7@RADI@7@SMITH@7@TANEA@) 2r!m 3u4"5

GREATEST $$$$$$$$ TANEA

LEAST 0E ST1e.pr8, e.pr@, e.pr+,e.pr;...2 !t is si)illar to greatest. !t returns the least e.pr fro) the e.pression list. e"e'# "e4 #(*-72-7;-72-7.-) 2r!m 3u4"5 LEAST $$$$$$$$ *-

e"e'# "e4 #(@SAMI@7@SCOTT@7@RADI@7@SMITH@7@TANEA@) 2r!m 3u4"5 LEAST $$$$$$$$ RADI

N(L $'0@1e.pr8,e.pr@2 This function is oftenly used to checD null values. !t returns e.pr@ if the e.pr8 is null, otherwise returns e.pr8. E.a)ple The following query returns co))ission if co))ission is null then returns E$ot pplicableE. Se"e'# en4me7nH"('!mm7@N!# A88")'4b"e@) 0C!mm1 2r!m 3u4"5 ENAME $$$$$$ S'!## T)6er S4m) R4H) T4nI4 COMM $$$$ .-/;N!# A88")'4b"e .-N!# A88")'4b"e

N(L) $'0@1e.pr8,e.pr@,e.pr+2 $'0@ returns e.pr@ if e.pr8 is not null, otherwise return e.pr+. E.a)ple The following query returns salaryIco)) if co)) is not null, otherwise Hust returns salary. e"e'# 4"4rI7'!mm7nH"2('!mm7 4"4rIM'!mm7 4"4rI) 0In'!me1 2r!m em85

SALARE $$$$$$ *--2--2.-./--

COMM $$$$ *-2--

INCOME $$$$$$ **-2--2;-./--

N#LLIF $600!41e.pr8, e.pr@2 $ullif co)pares e.pr8 with e.pr@. !f they are equal then returns null, otherwise return e.pr8. E.a)ple. The following query shows old Hobs of those e)ployees who have changed their Hobs in the co)pany by co)paring the current Hob with old Hob in olde)p table. Se"e'# en4me7nu"")2(e+G!b7!+G!b) 0O"3 B!b1 2r!m em8 e7 !"3em8 ! 9?ere e+em8n!K!+em8n!5 ENAME $$$$$ SMITH SAMI SCOTT OLD BOB $$$$$$$ CLERC MANAGER

#ID Returns the current session !5 of user logged on. E.a)ple e"e'# u)3 2r!m 3u4"5 UID $$$$ 2#SER

Returns the userna)e of the current user logged on. e"e'# u er 2r!m 3u4"5 USER $$$$$$$$$ SCOTT

S*S+CONTE!T S&S:"#$TEJT returns the value of parameter associated with the conte.t namespace. &ou can use this function in both SG0 and A0KSG0 state)ents. EJ *A0E The following query returns the userna)e of the current user. Se"e'# I ('!n#e:#(@USEREND@7@SESSION(USER@) 0U ern4me1 2r!m 3u4"5 USERNAME $$$$$$$$$ SCOTT

Si)ilar to SESS!#$:6SER para)eter for na)espace 6SERE$' the other i)portant para)eters are !S5% H#ST !$ST $"E -To checD whether the current user is having 5% privileges or not. -Returns the na)e of host )achine fro) which the client is connected. -The instance identification nu)ber of the current instance

!A: 55RESS- !A address of the )achine fro) which the client is connected. 5%:$ *E para)eter (SI,E 'S!BE1e.pr2 -$a)e of the database as specified in the 5%:$ *E initialiCation

Returns the internal representation of e.pr in bytes. E.a)ple The following query return the representation of ena)e in bytes. e"e'# en4me7H )Je(en4me) 4 ENAME $$$$$$ SCOTT SAMI RADI CIRAN BETES $$$$$$ ; / / ; BI#e 2r!m em85

Aggreg&te Functions
ggregate functions return a single value based on groups of rows, rather than single value for each row. &ou can use ggregate functions in select lists and in ORDER BY and HAVING clauses. They are co))only used with the GROUP BY clause in a SELECT state)ent, where #racle divides the rows of a queried table or view into groups. The i)portant ggregate functions are vg Su) *a. *in "ount Stddev 'ariance

A("
'(1 00 K5!ST!$"T Returns the average value of e.pr. E.a)ple The following query returns the average salary of all e)ployees. e"e'# 4H6( 4") 0AHer46e S4"4rI1 2r!m em85 AHer46e S4"4rI -----------------------@;99.;9 e.pr2

S#M
S6*1 00K5!ST!$"T Returns the su) value of e.pr. E.a)ple e.pr2

The following query returns the su) salary of all e)ployees. e"e'# um( 4") 0T!#4" S4"4rI1 2r!m em85

T!#4" S4"4rI -----------------------@=<99

MA!
* J1 00K5!ST!$"T Returns )a.i)u) value of e.pr. e.pr2

E.a)ple

The following query returns the )a. salary fro) the e)ployees.

e"e'# m4:( 4") 0M4: S4"4rI1 2r!m em85

M4:)mum S4"4rI ------------------------

;<99

MIN
*!$1 00K5!ST!$"T e.pr2

Returns )ini)u) value of e.pr. E.a)ple The following query returns the )ini)u) salary fro) the e)ployees. e"e'# m)n( 4") 0M)n S4"4rI1 2r!m em85 M)n)mum S4"4rI -----------------------8@99

CO#NT
"#6$T1F2 #R "#6$T1 00K5!ST!$"T e.pr2

Returns the nu)ber of rows in the query. !f you specify e.pr then count ignore nulls. !f you specify the asterisD 1F2, this function returns all rows, including duplicates and nulls. "#6$T never returns null. E.a)ple The following query returns the nu)ber of e)ployees. Se"e'# '!un#(L) 2r!m em85 COUNT $$$$$$ */

The following query counts the nu)ber of e)ployees whose salary is not null.

Se"e'# '!un#( 4") 2r!m em85 COUNT $$$$$$ *2

STDDE(
ST55E'1 00K5!ST!$"T e.pr2
STDDEV

returns sa)ple standard deviation of expr, a set of nu)bers.

E.a)ple The following query returns the standard deviation of salaries. e"e'# S#33eH $$$$$$$ */.#33eH( 4") 2r!m em85

(ARIANCE
' R! $"E1 00K5!ST!$"T 'ariance returns the variance of expr. E.a)ple The following query returns the variance of salaries. e"e'# H4r)4n'e( 4") 2r!m em85 D4r)4n'e $$$$$$$ */.e.pr2

Character functions.
Descri-tion E.&m-le Returns the S"!! code of the first ASCII(s) ASCII(@#e #@) K **, character of the string s. Returns the character with the S"!! CHR(**,) K @#@ CHR(i) code i. CONCAT(s17 "#$" T1EWelE, Eco)eE2 L Returns string s2 appended to s1. s2) EWelco)eE Returns the string s with the first INITCAP(@?e""! SIR@) K INITCAP(s) character of each word in uppercase @He""! S)r@ and all others in lowercase. Returns the nu)eric character position in s where the n-th occurrence of sub is found. The search begins at the position pos in s. INSTR(s7 subO7 posO7 !f the substring not found, it returns 9. INSTR(@#e #@7 @#@7 2) K / nPP) !f the pos is negative, the search is perfor)ed bacDwards 1fro) right to left2. The default values for pos and n are 8. Returns the nu)ber of characters in LENGTH(@We"'!me S)r@) K ** LENGTH(s) the string s. Returns the string s with all characters LOWER(@We"'!me S)r@) K LOWER(s) @9e"'!me )r@ in lowercase. Returns the string s e.panded in LPAD(s7 iO7 LPAD(@#e #@7 **7 @L$@) K length to i characters, using s1 to fill @L$L$L$L#e #@ s1P) in space as needed on the le/t side. Returns s without any leading LTRIM(@9e"'!me@7 @ "!9@) K character that appear in s1. !f no s1 LTRIM(s7 s1) character are leading characters in s, @e"'!me@ then s is returned unchanged. Returns the string s e.panded in RPAD(s7 iO7 LPAD(@#e #@7 **7 @L$@) K length to i characters, using s1 to fill @#e #L$L$L$L@ s1P) in space as needed on the rig%t side. Returns s without any trailing RTRIM(@M) ) )88)@7 @8)@) character that appear in s1. !f no s1 RTRIM(s7 s1) character are trailing characters in s, K @M) ) @ then s is returned unchanged. Returns s with all occurrences of REPLACE(@999+I4?!!+'!m@7 REPLACE(s7 substring s1 replaced with s2. %y @I4?!!@7 @6!!6"e@) K s1O7 s2P) default s2 is $600 and all @999+6!!6"e+'!m@ occurrences of s1 are re)oved. SUBSTR(s7 Returns the portion of the string s that SUBSTR(@9e"'!me@7 /) K posO7 lenP) @'!me@ is len characters long, beginning at position pos. !f pos is negative, the Function

position is counted bacDwards fro) the end of the string. The function returns $600 if len is less or equal to Cero. !f len is sDipped, it returns the re)aining of s. Returns the sounde. phonetic SOUNDEX(@B!?n@) K B;-- K representation of the string s. !tEs SOUNDEX(s) SOUNDEX(@B!n@) useful when we need to find words that sound liDe a given one. Returns the string s with all occurrences of characters in s1 TRANSLATE(@4"24be#@7 TRANSLATE(s7 replaced with the positionally @4b '3e@7 @BCDE@) K s17 s2) corresponding characters is s2.!f s2 is @B"2BC#@ shorter than s1, the un)atched characters in s1 are re)oved. This function returns the string s with all s1 1leading, trailing, or both2 occurrences of characters in s TRIM(Os1 A9 re)oved. !f present A9 is one of the TRIM(BOTH @+@ FROM FROMP s) @e#' +++@) K @e#' @ following LEADING, TRAILING, or BOTH 1by default itEs BOTH2. The default value of s1 is a space character. Returns the string s with all characters UPPER(@We"'!me S)r@) K UPPER(s) @WELCOME SIR@ in uppercase.

Numeric functions.
Function
ABS(d) ACOS(d) ASIN(d) ATAN(d) ATAN2(d17 d2) BITAND(i17 i2) CEIL(d) COS(d) COSH(d) EXP(d) FLOOR(d) LN(d)

Descri-tion Returns the absolute value of the double d. Returns the arc cosine of the value d e.pressed in radians 1d should be between -8 and 82. Returns the arc sine of the value d e.pressed in radians 1d should be between -8 and 82. Returns the arc tangent of the value d e.pressed in radians. Returns the arc tangent of the value d1/d2 e.pressed in radians. Returns the bitwise $5 operation perfor)ed on two integer argu)ents i1 and i2. The result is also an integer. Returns the s)allest integer that is greater or equal to d. Evaluates the cosine of d radians. Returns the hyperbolic cosine of d. Returns ed Returns the largest integer less or equal to d. Returns the natural logarith) of d.

Returns logbd. Returns i1 )odulo i2, or the re)inder of i1 divided i2. POWER(d7 p) Returns d to the pth power 1dp2. Returns d rounded to i digits of precision to the right of the deci)al point. ROUND(d7 i) !f i is negative, d is rounded to the left of the deci)al point. SIGN(d) Returns -8 if d is negative, 8 if d is positive, and 9 if d is Cero. SIN(d) Evaluates the sine of d radians. SINH(d) Returns the hyperbolic sine of d. SQRT(d) Returns the square root of d. TAN(d) Evaluates the tangent of d radians. TANH(d) Returns the hyperbolic tangent of d. Returns d truncated to i digits of precision to the right of the deci)al TRUNC(d7 i) point. !f i is negative, d is truncated to the left of the deci)al point.
LOG(b7 d) MOD(i17 i2)

Date functions.
!)plicit 5ate-to-String conversion is based on the value of the NLS(DATE(FORMAT variable. To change its value use the ALTER SESSION co))andALTER SESSION SET NLS(DATE(FORMAT K @DD$MM$EEEE HH2/QMIQSS@5

Descri-tion E.&m-le Returns the date dt plus i )onths. !f i is a deci)al nu)ber. #racle will ADD_MONTHS(dt7 ADD(MONTHS(SESDATE7 2) K auto)atically convert it to an i) @-*$SEP$2--. *2Q--Q-.@ integer by truncating the deci)al portion 1it )ay also be negative2. Returns the current date in the CURRENT(DATE K @-*$BUL$ CURRENT_DATE (regorian calendar for the sessionEs 2--. *2Q--Q.;@ ti)e Cone. !t requires no argu)ents. Returns the current date and ti)e in the sessionEs ti)e Cone to p digits of the precision, p should be an CURRENT(TIMESTAMP(/) K CURRENT_TIMESTAM integer 9 through M and defaults to @-*$BUL$-. *2Q--Q;*+%2,* P(OpP) =. The return datatype is PM $-/Q--@ T!*EST *A W!TH T!*E B#$E. 1See also 0#" 0T!*EST *A2 DBTIMEZONE Returns the databaseEs ti)e Cone, as DBTIMEFONE L E-9/-99E set by the latest CREATE DATABASE or ALTER DATABASE SET TIME(FONE state)ent. The ti)e Cone is a string specifying the hours and )inutes offset fro) 6T" 1"oordinated 6niversal Ti)eCone, aDa as (*T, or (reenwich *ean Ti)e2 or a ti)e Cone regional

Function

na)e. The valid ti)e Cone regional na)e can be found in the TB$ *E colu)n of the view
DRTIMEFONE(NAMES

Returns the co)ponent specified by c fro) the dateKti)e or interval dt. The valid co)ponents areN N T!*EB#$E:H# *!$6 N 6R TE &E R N N EXTRACT(c FROM EXTRACT(MONTH FROM N T!*EB#$E:*!$ SE"# SESDATE) K & dt) *#$T 6TE $5 H N N T!*EB#$E:RE( 5 & !#$ N N H#6R T!*EB#$E: % %R Returns a ti)esta)p with ti)e Cone for the ti)esta)p ts using the ti)e FROM(TF(LOCALTIMESTAMP7 @M.Q--@) K @-*$BUL$-. Cone value tz. The string tz FROM_TZ(ts7 tz) *2Q-*Q;&+,&S%;- PM specifies the hours and )inutes offset fro) 6T" or is a ti)e Cone M-.Q--@ region na)e. Returns the last day of the )onth LAST(DAE(@2;$Feb$2--/@) K LAST_DAY(dt) @2S$FEB$2--/ --Q--Q--@ for the date dt. Returns the current date and ti)e in the sessionEs ti)e Cone to p digits of the precision, p should be an LOCALTIMESTAMP(O LOCALTIMESTAMP(2) K @-*$ integer 9 through M and defaults to BUL$-. *2Q-2Q/%+;S PM@ pP) =. This function is si)ilar to the "6RRE$T:T!*EST *A, but the return datatype is T!*EST *A. Returns the nu)ber of )onths that dt1 is later than dt2. whole MONTHS_BETWEEN(d MONTHS(BETWEEN(@-*$BAN$ nu)ber is returned if dt1 and dt2 t17 dt2) 2--.@7 SESDATE) K $, are the sa)e day of the )onth or if both are th last day of the )onth. Returns the date in ti)e Cone tz2 NEW(TIME(SESDATE7 @EST@7 NEW_TIME(dt7 @PDT@) K @-*$BUL$2--. for the date dt in ti)e Cone tz1 . See tz17 tz2) *-Q-/Q/&@ ti)e Cone constants NEXT_DAY(dt7 s) Returns the date that corresponds to NEXT(DAE(SESDATE7 @M!n@) the ne.t day of weeD specified by K @-&$BUL$2--. *2Q-;Q*.@ the string s following the date dt.

The ti)e portion of the date is the sa)e as the ti)e portion of dt. The string s should be a te.t string containing the full or abbreviated day of the weeD in the sessionEs language. Returns the date dt rounded to the granularity specified in the dateROUND(dtO7 fmtP) for)at string fmt. See date for)at codes. Returns the databaseEs ti)e Cone as SESSIONTIMEZONE per the last LATER SESSION state)ent. !t taDes no argu)ents.
SYS_EXTRACT_UTC( ts)

ROUND(SESDATE7 @HH2/@) K @-*$BUL$2--. **Q--Q--@

SESSIONTIMEFONE K @$ -/Q--@ CURRENT(TIMESTAMP K @-*$ BUL$-. **+/%+*S+,*%/2% AM $-/Q--@ SES(EXTRACT(UTC(CURRENT(T IMESTAMP) K @-*$BUL$-. -.Q/&Q-;+S*&-&% PM@ SESDATE K @-*$BUL$2--. **Q;-Q-%@

Returns the 6T" 1(*T2 ti)e Cone fro) the ti)esta)p ts.

Returns the current dateKti)e, taDes no argu)ents. TaDes no argu)ents and returns a T!*EST *A W!TH T!*E B#$E for the current database date and SYSTIMESTAMP ti)e. The fractional second is returned with si. digits of precision. Returns the date dt truncated to the TRUNC(dtO7 fmtP) granularity specified by the for)at string fmt. Returns the nu)eric ti)e Cone TZ_OFFSET(tz) offset for the te.tual ti)e Cone na)e tz.
SYSDATE

SESTIMESTAMP K @-*$BUL$-. **Q;2Q*-+-;*2.& AM $-/Q--@

TRUNC(SES34#e7 @DD@) K @-*$BUL$2--. --Q--Q--@ TF(OFFSET(@USTE4 #ern@) K @$-/Q--@

Conversion functions.
Descri-tion ASCIISTR(s) Returns the S"!! equivalent of all characters in the string s. TaDes a single argu)ent bit_list - the co))a-deli)ited list of BIN_TO_NUM(bit_list) bits, and returns the nu)eric representation of all the bit-field set bit_list. "onverts the e.pression expr into datatype type. The expr can CAST(expr AS type) be an e.pression, subquery, or *60T!SET clause. See the possible conversion table for standard datatypes. CHARTOROWID(s) Returns the string s as a R#W!5 datatype. COMPOSE(s) Returns the string s as a 6nicode string in its fully nor)aliCed Function

CONVERT(s7 dsetO7 ssetP) DECOMPOSE(s) HEXTORAW(x)

NUMTODSINTERVAL(x7 st)

NUMTOYMINTERVAL(x7 st) RAWTOHEX(rs) ROWIDTOCHAR(x)

TO_CHAR(xO7 fmtO7 nlsPP)

TO_DATE(sO7 fmtO7 nlsPP) TO_DSINTERVAL(sO7 nlsP) TO_NUMBER(sO7 fmtO7 nlsPP) TO_YMINTERVAL(s) UNISTR(s)

for), in the sa)e characters set as s. Returns the string s converted fro) the soursecharacter set sset to the destination character set dset. Returns the string s as a 6nicode string after canonical deco)position in the sa)e character set as s. Returns the he.adeci)al string x converted to a R W datatype. "onverts the nu)ber x into an !$TER' 0 5 & T# SE"#$5 datatype accordingly to the string st denoting the units for x. 'alid units are- @DAE@, @HOUR@, @MINUTE@, and @SECOND@. "onverts the nu)ber x into an !$TER' 0 &E R T# *#$TH datatype accordingly to the string st denoting the units for x. 'alid units are- @EEAR@ and @MONTH@. Returns the raw string rs converted to he.adeci)al. Returns the string x 1in the for)at of R#W!52 converted fro) R#W!5. TaDes up to three argu)ents, where x is either a date or a nu)ber, fmt is a for)at string specifying the for)at that x will appear in, and nls specifies language or location for)atting string. !f x is a date, fmt is a date for)at code. !f x is a nu)ber, fmt is a nu)eric for)at code. "onverts string s to 5 TE datatype accordingly the for)at string fmt. The fmt string uses the sa)e date for)at code. The default is the value stored in the NLS(DATE(FORMAT session variable. Returns the string s converted into an INTERDAL DAE TO SECOND datatype. Returns the nu)eric value represented by the string s. The for)at string fmt specifies the for)at the that s appears in. Returns the string s converted into an INTERDAL EEAR TO MONTH datatype. Returns the string s in 6nicode in the database 6nicode character set.

Other functions.
Function Descri-tion TaDes two argu)ents, where dir is a string containing a directory na)e and file is a string containing a file na)e. Returns an e)pty %4!0E locator. When used, the %4!0E is instantiated. $either dir nor file needs to e.ist at the ti)e the function is called, but both )ust e.ist when the locator is used.

BFILENAME(dir7 file)

COALESCE(expr_list)

DECODE(x7 v17 r1O7 v27 r2 +++PO7 dP)

Returns the first non-$600 value in the expr_list. !f all e.pressions are $600, then $600 is returned. Each e.pression in the expr_list should be the sa)e type. The function co)pares the value of the e.pression x with values of the argu)ents v1, v2, etc. !f the value of x is equivalent to v1, then r1 is returned7 otherwise the additional)atching e.pressions are co)pared. !f no )atch is found and the default e.pression d is included, then the d is returned. !f no )atch is found and there is no d argu)ent, then $600 is returned. E.a)pleSELECT )37 er)4"U7 u ern4me7 DECODE('!mm4n37 -7 @N!ne@7 27 @In #er#@7 .7 @Se"e'#@7 ,7 @U834#e@7 &7 @De"e#e@7 %7 @Dr!8@7 @O#?er@) 'm3 FROM HR e )!n WHERE #I8e VW @BACCGROUND@5

TaDes up to four argu)ents, where x is an e.pression, fmt is a for)at specification for N octal 1899,2, N deci)al 189892, DUMP(xO7 fmtO7 sbO7 N he.adeci)al 1898=2, lenPPP) N or single character 1898/2 , sb is the starting byte offset within x, and len is the length in bytes to du)p. The function returns a character string containing the datatype of x in nu)eric notation and the internal presentation of x. Returns an e)pty %0#% locator. This function is used to EMPTY_BLOB initialiCe a %0#% variable or %0#% colu)n in a table. Returns an e)pty "0#% locator. This function is used to EMPTY_CLOB initialiCe a "0#% variable or "0#% colu)n in a table. Returns the e.pression fro) the expr_list that sorts the highest in the datatype of the first e.pression. !f the GREATEST(expr_list) e.pression list contains a $600, then a $600 is returned. Returns the e.pression fro) the expr_list that sorts the lowest in the datatype of the first e.pression. !f the LEAST(expr_list) e.pression list contains a $600, then a $600 is returned. Returns $600 if the e.pression x1 is equal to x27 NULLIF(x17 x2) otherwise returns x1. SYS_CONNECT_BY_PATH(col7 This function worDs only with hierarchical queries chr)

queries that use CONNECT BE clause. !t returns the path of colu)n col, deli)ited by the character chr, fro) root to node for each row returned by the CONNECT BE condition. E.a)pleSELECT 3e8()37 3e8(n4me7 SYS_CONNECT_BY_PATH(3e8(n4me7 @$@) @De8+ C?4)n@ FROM 3e84r#men# START WITH 3e8()3 K CONNECT BE PRIOR 3e8()3 K u8(3e8()35

SYS_CONTEXT(ns7 parO7 lenP)

TaDes up to three argu)ents, where ns is a na)espace, par is a para)eter associated with the na)espace ns, and len is the length of the return value in bytes 1default @<=2. The built-in na)espace USEREND contains infor)ation on the current session. See the table with para)eters in the
USEREND

UID USER

USERENV(opt)

VSIZE(x)

Returns the integer user !5 for the current user. Returns a character string containing the userna)e for the current user. TaDes a single argu)ent, where opt is one of the following optionsN !S5% N SESS!#$!5 N E$TR&!5 N !$ST $"E N 0 $(6 (E N 0 $( N TER*!$ 0 This function is deprecated in release #racleMi. Returns the siCe in bytes of the internal representation of the e.pression x.

You might also like