Download presentation
Presentation is loading. Please wait.
Published byTamsin Wilson Modified over 8 years ago
1
8 1 Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel
2
8 2 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Numeric Functions
3
8 3 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel String Functions
4
8 4 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel String Functions (continued)
5
8 5 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Conversion Functions
6
8 6 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Conversion Functions (continued)
7
8 7 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Oracle Sequences
8
8 8 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Oracle Sequences (continued)
9
8 9 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Updatable Views
10
8 10 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Updatable Views (continued)
11
8 11 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Updatable Views (continued)
12
8 12 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Updatable Views (continued)
13
8 13 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Procedural SQL
14
8 14 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Procedural SQL (continued) SHOW ERRORS –Can help diagnose errors found in PL/SQL blocks –Yields additional debugging information whenever error is generated after creating or executing a PL/SQL block
15
8 15 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Procedural SQL (continued)
16
8 16 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Procedural SQL (continued)
17
8 17 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Triggers
18
8 18 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Triggers (continued)
19
8 19 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Triggers (continued)
20
8 20 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Triggers (continued)
21
8 21 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Triggers (continued)
22
8 22 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Triggers (continued)
23
8 23 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Triggers (continued)
24
8 24 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Triggers (continued)
25
8 25 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Triggers (continued)
26
8 26 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Triggers (continued)
27
8 27 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Triggers (continued)
28
8 28 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Stored Procedures Advantages –Substantially reduce network traffic and increase performance No transmission of individual SQL statements over network –Help reduce code duplication by means of code isolation and code sharing Minimize chance of errors and cost of application development and maintenance
29
8 29 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Stored Procedures (continued)
30
8 30 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Stored Procedures (continued)
31
8 31 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Stored Procedures (continued)
32
8 32 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Stored Procedures (continued)
33
8 33 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Stored Procedures (continued)
34
8 34 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Stored Procedures (continued)
35
8 35 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Stored Procedures (continued)
36
8 36 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel PL/SQL Processing with Cursors
37
8 37 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel PL/SQL Processing with Cursors (continued)
38
8 38 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel PL/SQL Processing with Cursors (continued)
39
8 39 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel PL/SQL Stored Functions Syntax: –CREATE FUNCTION function_name (argument IN data-type, …) RETURN data- type [IS] BEGIN PL/SQL statements; … RETURN (value or expression); END;
40
8 40 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Embedded SQL Key differences between SQL and procedural languages are: –Run-time mismatch SQL executed one instruction at a time Host language typically runs at client side in its own memory space –Processing mismatch Host language processes one data element at a time –Data type mismatch Data types may not match
41
8 41 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Embedded SQL (continued) Embedded SQL framework defines: –Standard syntax to identify embedded SQL code within host language –Standard syntax to identify host variables –Communication area used to exchange status and error information between SQL and host language
42
8 42 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Embedded SQL (continued)
43
8 43 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Embedded SQL (continued) Static SQL –Embedded SQL in which programmer used predefined SQL statements and parameters End users of programs are limited to actions that were specified in application programs –SQL statements will not change while application is running
44
8 44 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Embedded SQL (continued) Dynamic SQL –SQL statement is not known in advance, but instead is generated at run time –Program can generate SQL statements at run time that are required to respond to ad hoc queries –Attribute list and condition are not known until end user specifies them –Tends to be much slower than static SQL –Requires more computer resources
45
8 45 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Summary SQL provides relational set operators to combine output of two queries to generate new relation Operations that join tables can be classified as inner joins and outer joins Natural join returns all rows with matching values in the matching columns and eliminates duplicate columns
46
8 46 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Summary (continued) Joins may use keywords, such as USING and ON Subqueries and correlated queries are used when it is necessary to process data based on other processed data Most subqueries are executed in serial fashion
47
8 47 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Summary (continued) SQL functions are used to extract or transform data Oracle sequences may be used to generate values to be assigned to a record PL/SQL can be used to create triggers, stored procedures, and PL/SQL functions A stored procedure is a named collection of SQL statements
48
8 48 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Summary (continued) When SQL statements are designed to return more than one value inside the PL/SQL code, cursor is needed Embedded SQL refers to use of SQL statements within an application programming language
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.