Conversion functions – case

The CASE function provides the use of IF-THEN-ELSE logic within a SQL statement. It is an alternative for decode function. Syntax: CASE expr WHEN comparison_expr1 THEN return_expr1 [WHEN comparison_expr2 THEN return_expr2 ELSE else_expr ] END Example: SELECT CASE ‘man’ WHEN ‘lady’ THEN ‘hello lady’ WHEN ‘man’ THEN ‘hello man’ ELSE ‘hello someone’ END FROM DUAL […]
Continue reading…

Enjoyed this post? Share it!

 
 

Conversion functions – nullif

NULLIF function is used to return NULL if a condition matches. Syntax: NULLIF(expr1, expr2) If expr1 and expr2 are equal, the function returns NULL else it returns expr1 Example: SELECT NULLIF(’earth’, ‘earth’) FROM DUAL Output is NULL SELECT NULLIF(4*4, 3*2) FROM DUAL Output is : 12 SELECT NULLIF(8, 5) FROM DUAL Output is 8
Continue reading…

Enjoyed this post? Share it!

 
 

Conversion Functions – convert

The Oracle/PLSQL function convert replaces a string from one character set to another. Convert does not translate words but substitutes the letter in one character set with the corresponding letter in another character set. Syntax: CONVERT( string, destination_char_set, [ source_char_set ] ) string is the string to be converted. destination_char_set is the character set into […]
Continue reading…

Enjoyed this post? Share it!

 
 

Conversion Functions – DECODE()

DECODE is similar to if-then-else function. It takes a minimum of 4 arguments. The first argument is an expression or a value. The second argument is the value that has to be compared with the value in the first argument. The third argument is the value to be returned if there is a match between […]
Continue reading…

Enjoyed this post? Share it!

 
 

Conversion Functions – NVL()

The NVL function is used to replace NULL values by any other value. NVL takes two arguments. The first argument is the field to be checked for NULL. The second argument is the value that has to be replaced if the first argument returns NULL. Syntax: NVL( check_value, replace_value ) Example code: SELECT * FROM […]
Continue reading…

Enjoyed this post? Share it!