Chapter 10 Selected Single-Row Functions Oracle 10g: SQL

Slides:



Advertisements
Similar presentations
Copyright  Oracle Corporation, All rights reserved. 2 Single-Row Functions.
Advertisements

Objectives After completing this lesson, you should be able to do the following: Describe various types of conversion functions that are available in.
Copyright © 2007, Oracle. All rights reserved Using Single-Row Functions to Customize Output Modified: October 21, 2014.
Introduction to Oracle9i: SQL1 Selected Single-Row Functions.
Using Single-Row Functions to Customize Output
Lecture 6 29/1/15. Number functions Number functions take numbers as input, change them, and output the results as numbers. 2.
Ch. 3 Single-Row Functions Important Legal Notice:  Materials on this lecture are from a book titled “Oracle Education” by Kochhar, Gravina, and Nathan.
Single-Row Functions. SQL Functions Functions are a very powerful feature of SQL and can be used to do the following: Perform calculations on data Modify.
3-1 Copyright  Oracle Corporation, All rights reserved. SQL Functions FunctionInput arg 1 arg 2 arg n Function performs action OutputResultvalue.
3 Single-Row Functions. 3-2 Objectives At the end of this lesson, you should be able to: Describe various types of functions available in SQL Use character,
Oracle FUNCTIONS. Comment ScreenShot (in 10g) General Example of null Foreign Key: create table deptcs( deptno NUMBER(4) primary key, hiredate DATE,
Number Functions. 2 home back first prev next last Review single-row character functions –character case-manipulation functions  LOWER, UPPER, INITCAP.
3 Copyright © Oracle Corporation, All rights reserved. Single-Row Functions.
2-1 Copyright © Oracle Corporation, All rights reserved. Character Strings and Dates Character strings and date values are enclosed in single quotation.
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL.
Chapter 5 Selected Single-Row Functions. Chapter Objectives  Use the UPPER, LOWER, and INITCAP functions to change the case of field values and character.
Single-Row Functions. Two Types of SQL Functions There are two distinct types of functions: Single-row functions Multiple-row functions Single-Row Functions.
SINGLE-ROW FUNCTIONS Lecture 9. SQL Functions Functions are very powerful feature of SQL and can be used to do the following:  Perform a calculation.
Functions Oracle Labs 5 & 6. 2/3/2005Adapted from Introduction to Oracle: SQL and PL/SQL 2 SQL Functions Function arg n arg 2 arg 1. Input Resulting Value.
3 Copyright © 2004, Oracle. All rights reserved. Using Single-Row Functions to Customize Output.
Single – Row Functions. Objectives After completing this lesson, you should be able to do the following:  Describe various types of functions available.
Copyright  Oracle Corporation, All rights reserved. 3 Single-Row Functions.
Single Row Functions Week 2. Objectives –Describe types of single row functions in SQL –Describe and use character, number, date, general and conversion.
Oracle 11g: SQL Chapter 10 Selected Single-Row Functions.
SQL Oracle PL/SQL. Select SELECT column1, column2,...columnN FROM table_name WHERE condition; SELECT column1, column2,...columnN FROM table_name WHERE.
Chapter 3 Selected Single-Row Functions and Advanced DML & DDL.
6 Copyright © 2006, Oracle. All rights reserved. Using Single-Row Functions to Customize Output.
2-1 Copyright © Oracle Corporation, All rights reserved. Using the NULL Conditions Test for nulls with the IS NULL operator. SELECT last_name, manager_id.
EXPRESSION Transformation. Introduction ►Transformations help to transform the source data according to the requirements of target system and it ensures.
IFS Intro to Data Management Chapter 5 Getting More Than Simple Columns.
Conversion Functions.
Single Row Functions. Objectives –Use character, number, and date functions –Use conversion functions –Describe types of single row functions in SQL.
Single-Row Functions. SQL Functions FunctionInput arg 1 arg 2 arg n Function performs action OutputResultvalue.
Copyright  Oracle Corporation, All rights reserved. 3 Single-Row Functions.
3 Copyright © 2009, Oracle. All rights reserved. Using Single-Row Functions to Customize Output.
3 Copyright © Oracle Corporation, All rights reserved. Single-Row Functions.
Copyright س Oracle Corporation, All rights reserved. 3 Single-Row Functions.
3 Copyright © Oracle Corporation, All rights reserved. Single-Row Functions.
3 第三讲 Single-Row Functions. Objectives After completing this lesson, you should be able to do the following: Describe various types of functions available.
6 Copyright © Oracle Corporation, All rights reserved. Subqueries.
SQL Functions. SQL functions are built into Oracle Database and are available for use in various appropriate SQL statements. These functions are use full.
Built-in SQL Functions. 2 Type of Functions Character Functions returning character values returning numeric values Numeric Functions Date Functions Conversion.
Using Single-Row Functions to Customize Output
Oracle & SQL. Oracle Data Types Character Data Types: Char(2) Varchar (20) Clob: large character string as long as 4GB Bolb and bfile: large amount of.
3 Copyright © 2007, Oracle. All rights reserved. Substitution Variables ra Oly l&On nase lce Int erU.
4/2/16. Ltrim() is used to remove leading occurrences of characters. If we don’t specify a character, Oracle will remove leading spaces. For example Running.
1 Inside Module 8 Extracting Data Page n Using the Extract command2 n Coercion3 n $-functions4 n Extract from a table7.
Gollis University Faculty of Computer Engineering Chapter Five: Retrieval, Functions Instructor: Mukhtar M Ali “Hakaale” BCS.
3 Copyright © 2009, Oracle. All rights reserved. Using Single-Row Functions to Customize Output.
Single Row Functions. 3-2 Objectives Explain the various types of functions available in SQL. Explain the various types of functions available in SQL.
Copyright  Oracle Corporation, All rights reserved. 3 Single-Row Functions.
Single Row Functions Part I Week 2. Objectives –Describe types of single row functions in SQL –Describe and use character, number and date SQL functions.
Enhanced Guide to Oracle 10g
Open Source Server Side Scripting MySQL Functions
Using Single-Row Functions to Customize Output
Restricting and Sorting Data
Using Single-Row Functions to Customize Output
SQL DATE/TIME FUNCTIONS
Chapter Nine Data Manipulation Language (DML) Functions
SQL 101 3rd Session.
Computations Done on table data
Using Single-Row Functions to Customize Output
(SQL) Single-Row Functions
SQL 101 2nd Session.
Single-Row Functions Lecture 9.
Index Note: A bolded number or letter refers to an entire lesson or appendix. A Adding Data Through a View ADD_MONTHS Function 03-22, 03-23,
Contents Preface I Introduction Lesson Objectives I-2
Inside Module 8 Extracting Data Page Using the Extract command 2
Lecture 5 SQL FUNCTIONS.
Chapter 1 Overview of Database Concepts
Presentation transcript:

Chapter 10 Selected Single-Row Functions Oracle 10g: SQL

Objectives Use the UPPER, LOWER, and INITCAP functions to change the case of field values and character strings Extract a substring using the SUBSTR function Locate a substring within a character string with the INSTR function Nest functions inside other functions Determine the length of a character string using the LENGTH function Use the LPAD and RPAD functions to pad a string to a certain width Oracle 10g: SQL

Objectives (continued) Use the LTRIM and RTRIM functions to remove specific characters strings Substitute character string values with the REPLACE and TRANSLATE functions Round and truncate numeric data using the ROUND and TRUNC functions Return the remainder only of a division operation using the MOD function Calculate the number of months between two dates using the MONTHS_BETWEEN function Manipulate date data using the ADD_MONTHS, NEXT_DAY, TO_DATE, and ROUND functions Oracle 10g: SQL

Objectives (continued) Extend pattern matching capabilities with regular expressions Identify and correct problems associated with calculations involving NULL values using the NVL function Display dates and numbers in a specific format with the TO_CHAR function Perform condition processing similar to an IF statement with the DECODE function Use the SOUNDEX function to identify character phonetics Use the DUAL table to test functions Oracle 10g: 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 (covered in the next chapter) Oracle 10g: SQL

Types of Functions Oracle 10g: SQL

Case Conversion Functions Case conversion functions alter the case of data stored in a column or character string: Used in a SELECT clause they alter the appearance of the data in the results Used in a WHERE clause they alter the value for comparison Oracle 10g: SQL

LOWER Function Used to convert characters to lowercase letters Oracle 10g: SQL

UPPER Function Used to convert characters to uppercase letters It can be used in the same way as the LOWER function: To affect the display of characters it is used in a SELECT clause To modify the case of characters for a search condition it is used in a WHERE clause The syntax for the UPPER function is UPPER(c) Where c is the character string or field to be converted into uppercase characters Oracle 10g: SQL

INITCAP Function Used to convert characters to mixed case Oracle 10g: SQL

Character Manipulation Functions Character manipulation functions manipulate data by extracting substrings, counting the number of characters, replacing strings, etc. Oracle 10g: SQL

SUBSTR Function Used to return a substring, or portion of a string Oracle 10g: SQL

INSTR Function Oracle 10g: SQL

Nesting Functions Oracle 10g: SQL

LENGTH Function Used to determine the number of characters in a string Oracle 10g: SQL

LPAD and RPAD Functions Used to pad, or fill in, a character string to a fixed width Oracle 10g: SQL

LTRIM and RTRIM Functions Used to remove a specific string of characters Oracle 10g: SQL

REPLACE Function Substitutes a string with another specified string Oracle 10g: SQL

TRANSLATE Function Oracle 10g: SQL

CONCAT Function Used to concatenate two character strings Oracle 10g: SQL

Number Functions Allow for manipulation of numeric data: ROUND TRUNC MOD ABS Oracle 10g: SQL

ROUND Function Used to round numeric columns to a stated precision Oracle 10g: SQL

TRUNC Function Used to truncate a numeric value to a specific position Oracle 10g: SQL

MOD Function Oracle 10g: SQL

ABS Function Oracle 10g: SQL

Date Functions Used to perform date calculations or format date values Subtract date for number of days difference Oracle 10g: SQL

MONTHS_BETWEEN Function Determines the number of months between two dates Oracle 10g: SQL

ADD_MONTHS Function Adds a specified number of months to a date Oracle 10g: SQL

NEXT_DAY Function Determines the next occurrence of a specified day of the week after a given date Oracle 10g: SQL

TO_DATE Function Converts various date formats to the internal format (DD-MON-YY) used by Oracle 10g Oracle 10g: SQL

Format Model Elements - Dates Oracle 10g: SQL

ROUND Function Oracle 10g: SQL

TRUNC Function Oracle 10g: SQL

Regular Expressions Regular expressions allow the description of complex patterns in textual data Oracle 10g: SQL

REGEXP_LIKE Oracle 10g: SQL

Other Functions NVL NVL2 TO_CHAR DECODE SOUNDEX Oracle 10g: SQL

NVL Function Substitutes a value for a NULL value Oracle 10g: SQL

NVL2 Function Allows different actions based on whether a value is NULL Oracle 10g: SQL

TO_CHAR Function Converts dates and numbers to a formatted character string Oracle 10g: SQL

Format Model Elements – Time and Number Oracle 10g: SQL

DECODE Function Determines action based upon values in a list Oracle 10g: SQL

SOUNDEX Function References phonetic representation of words Oracle 10g: SQL

TO_NUMBER Function Oracle 10g: SQL

DUAL Table Dummy table Consists of one column and one row Can be used for table reference in the FROM clause Oracle 10g: SQL

Using DUAL Oracle 10g: SQL

Summary Single-row functions return a result for each row or record processed Character case conversion functions such as UPPER, LOWER, and INITCAP can be used to alter the case of character strings Nesting one function within another allows multiple operations to be performed on data Simple number functions such as ROUND and TRUNC can round or truncate a number on both the left and right side of a decimal Oracle 10g: SQL

Summary (continued) The MOD function is used to return the remainder of a division operation Date functions can be used to perform calculations with dates or to change the format of dates entered by a user Regular expressions enable complex pattern matching operations The NVL and NVL2 functions are used to address problems encountered with NULL values Oracle 10g: SQL

Summary (continued) The TO_CHAR function lets a user present numeric data and dates in a specific format The DECODE function allows an action to be taken to be determined by a specific value The SOUNDEX function looks for records based on the phonetic representation of characters The DUAL table can be helpful when testing functions Oracle 10g: SQL