Explain the steps executed
during SQL statement processing.
Oracle translate and decode - Dec 03, 2008 at 15:00 PM by
Rajmeet Ghai
What is translate and decode in oracle?
Translate:
translate function replaces a sequence of characters in a string with another
set of characters. The replacement is done single character at a time.
Syntax:
translate( string1, string_to_replace, replacement_string )
Example:
translate ('1tech23', '123', '456);
Decode:
The DECODE function compares one expression to one or more other
expressions and, when the base expression is equal to a search expression, it
returns the corresponding result expression; or, when no match is found,
returns the default expression when it is specified, or NA when it is not.
Syntax:
DECODE (expr , search, result [, search , result]... [, default])
Example:
SELECT employee_name, decode(employee_id, 10000, ‘tom’, 10001,
‘peter’, 10002, ‘jack’ 'Gateway') result FROM employee;
Also read
What are conversion functions?, What is nested function?, What is NVL function?,
What are SQL functions in oracle?............
Explain IN, OUT and INOUT in procedures, What are the rules of writing package?,
Explain the rules for writing a package..............
Object data types are user defined data types. Both column and row can represent
an object type.................
|