Comprehensive Guide to Single-Row Functions in Oracle 9i SQL
This chapter provides an in-depth exploration of single-row functions in Oracle 9i SQL, covering essential concepts and terminologies. We explain the use of case conversion functions like LOWER, UPPER, and INITCAP, alongside character manipulation functions such as SUBSTR, LENGTH, and REPLACE. Additionally, it introduces number and date functions, including ROUND, TRUNC, ADD_MONTHS, and TO_DATE. Special functions like NVL, NVL2, DECODE, and SOUNDEX are also discussed, providing practical guidance on how to leverage these functions effectively in SQL queries.
Comprehensive Guide to Single-Row Functions in Oracle 9i SQL
E N D
Presentation Transcript
Chapter 5Selected Single-Row Functions Introduction to Oracle9i: SQL
Terminology • Function – predefined block of code that accepts arguments • Single-row Function – returns one row of results for each record processed • Multiple-row Function – returns one result per group of data processed Introduction to Oracle9i: SQL
Types of Functions Introduction to Oracle9i: SQL
Case Conversion Functions Alter the case of data stored in a column or character string Introduction to Oracle9i: SQL
LOWER Function Used to convert characters to lower-case letters Introduction to Oracle9i: SQL
UPPER Function Used to convert characters to upper-case letters Introduction to Oracle9i: SQL
INITCAP Function Used to convert characters to mixed-case Introduction to Oracle9i: SQL
Character Manipulation Functions Manipulates data by extracting substrings, counting number of characters, replacing strings, etc. Introduction to Oracle9i: SQL
SUBSTR Function Used to return a substring, or portion of a string Introduction to Oracle9i: SQL
LENGTHFunction Used to determine the number of characters in a string Introduction to Oracle9i: SQL
LPADandRPADFunctions Used to pad, or fill in, a character string to a fixed width Introduction to Oracle9i: SQL
LTRIMandRTRIMFunctions Used to remove a specific string of characters Introduction to Oracle9i: SQL
REPLACEFunction Substitutes a string with another specified string Introduction to Oracle9i: SQL
CONCATFunction Used to concatenate two character strings Introduction to Oracle9i: SQL
Number Functions Allows for manipulation of numeric data Introduction to Oracle9i: SQL
ROUNDFunction Used to round numeric columns to a stated precision Introduction to Oracle9i: SQL
TRUNCFunction Used to truncate a numeric value to a specific position Introduction to Oracle9i: SQL
Date Functions Used to perform date calculations or format date values Introduction to Oracle9i: SQL
MONTHS_BETWEENFunction Determines the number of months between two dates Introduction to Oracle9i: SQL
ADD_MONTHSFunction Adds a specified number of months to a date Introduction to Oracle9i: SQL
NEXT_DAYFunction Determines the next occurrence of a specified day of the week after a given date Introduction to Oracle9i: SQL
TO_DATEFunction Converts various date formats to the internal format (DD-MON-YYYY) used by Oracle9i Introduction to Oracle9i: SQL
FormatModelElements - Dates Introduction to Oracle9i: SQL
NVL Function Substitutes a value for a NULL value Introduction to Oracle9i: SQL
NVL2 Function Allows different actions based on whether a value is NULL Introduction to Oracle9i: SQL
TO_CHAR Function Converts dates and numbers to a formatted character string Introduction to Oracle9i: SQL
FormatModelElements – TimeandNumber Introduction to Oracle9i: SQL
Other Functions • NVL • NVL2 • TO_CHAR • DECODE • SOUNDEX Introduction to Oracle9i: SQL
DECODEFunction Determines action based upon values in a list Introduction to Oracle9i: SQL
SOUNDEXFunction References phonetic representation of words Introduction to Oracle9i: SQL
NestingFunctions • One function is used as an argument inside another function • Must include all arguments for each function • Inner function is resolved first, then outer function Introduction to Oracle9i: SQL
DUALTable • Dummy table • Consists of one column and one row • Can be used for table reference in the FROM clause Introduction to Oracle9i: SQL