SCU Fall 2002JoAnne Holliday10–1 Schedule Today u Triggers, Procedures, PL/SQL. u Read Sections 7.4-7.5, 8.1, 8.5. Next u Transaction concepts, security.

Slides:



Advertisements
Similar presentations
Definition Cursor is a control structure for the successive traversal of records in a result set. Cursor is a record pointer in a database. DATABASE CURSOR.
Advertisements

PL/SQL.
AN INTRODUCTION TO PL/SQL Mehdi Azarmi 1. Introduction PL/SQL is Oracle's procedural language extension to SQL, the non-procedural relational database.
1 Database-Connection Libraries Call-Level Interface Java Database Connectivity PHP.
Chapter 9 SQL in a Server Environment Call-Level Interface Java Database Connectivity PHP.
1 Combining SQL and Conventional Programming Languages Source: slides by Jeffrey Ullman.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 Introduction to SQL Programming Techniques.
Fall 2001Arthur Keller – CS 18011–1 Schedule Oct. 30 (T) Embedded SQL. u Read Section 8.1. u Assignment 5 due. Not accepted late. u Project Part 4 due.
1 JDBC Java Database Connectivity. 2 c.pdf
Winter 2002Arthur Keller – CS 18010–1 Schedule Today: Feb. 5 (T) u Triggers, PL/SQL. u Read Sections 7.4, 8.2. Assignment 4 due. Feb. 7 (TH) u PL/SQL,
Winter 2002Arthur Keller – CS 1809–1 Schedule Today: Jan. 31 (TH) u Constraints. u Read Sections , Project Part 3 due. Feb. 5 (T) u Triggers,
Winter 2002Arthur Keller – CS 18011–1 Schedule Today: Feb. 7 (TH) u PL/SQL, Embedded SQL, CLI, JDBC. u Read Sections 8.1, Feb. 12 (T) Advising.
1 PL/SQL Oracle’s Version of Triggers and PSM. 2 PL/SQL uOracle uses a variant of SQL/PSM which it calls PL/SQL. uPL/SQL not only allows you to create.
1 SQL Programming Embedded SQL Call-Level Interface Java Database Connectivity Persistent Stored Modules.
1 CSC 440 Database Management Systems JDBC This presentation uses slides and lecture notes available from
CS411 Database Systems Kazuhiro Minami 07: SQL System Aspects.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 David M. Kroenke’s Chapter Seven: SQL for Database Construction and.
CSCI 6962: Server-side Design and Programming JDBC Database Programming.
Java Database Connectivity (JDBC) Introduction to JDBC JDBC is a simple API for connecting from Java applications to multiple databases. Lets you smoothly.
Announcements Read JDBC Project Step 5, due Monday.
1 Real SQL Programming Embedded SQL Call-Level Interface Java Database Connectivity.
SCUHolliday - coen 1789–1 Schedule Today: u Constraints, assertions, triggers u Read Sections , 7.4. Next u Triggers, PL/SQL, embedded SQL, JDBC.
Chapter 8 Using SQL in an Application. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 8-2 CSC 4480 outline Intro (3-9) Static SQL (10-11)
Winter 2006Keller, Ullman, Cushing10–1 Modification to Views Via Triggers Oracle allows us to “intercept” a modification to a view through an instead-of.
Stored procedures1 Stored procedures and functions Procedures and functions stored in the database.
Advanced SQL: Cursors & Stored Procedures
SCUJoAnne Holliday11–1 Schedule Today: u Transaction concepts. u Read Sections Next u Authorization and security.
Advanced SQL Instructor: Mohamed Eltabakh 1 Part II.
1 Real SQL Programming Persistent Stored Modules (PSM) PL/SQL Embedded SQL.
1 Real SQL Programming Embedded SQL Java Database Connectivity Stored Procedures.
Winter 2006 Keller, Ullman, Cushing 11–1 Embedded SQL Add to a conventional programming language (C in our examples) certain statements that represent.
Databases 1 9th lecture. Main topic: Oracle PL/SQL What is PL/SQL? ▫Procedural Langauge extension for standard SQL.. PL/SQL not only allows you to create.
Advanced SQL: Triggers & Assertions
What is a Package? A package is an Oracle object, which holds other objects within it. Objects commonly held within a package are procedures, functions,
Course FAQ’s I do not have any knowledge on SQL concepts or Database Testing. Will this course helps me to get through all the concepts? What kind of.
Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Chapter 4: SQL Complex Queries Complex Queries Views Views Modification of the Database Modification of the Database Joined Relations Joined Relations.
JDBC CS 124. JDBC Java Database Connectivity Database Access Interface provides access to a relational database (by allowing SQL statements to be sent.
Dr Gordon Russell, Napier University Unit Embedde SQL - V2.0 1 Embedded SQL Unit 5.1.
1 Real SQL Programming Persistent Stored Modules (PSM) PL/SQL Embedded SQL.
Chapter 4 An Introduction to SQL. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.4-2 Topics in this Chapter SQL: History and Overview The.
Database Access Using JDBC BCIS 3680 Enterprise Programming.
SQL Programming SQL in Application Programs
Introduction to JDBC Instructor: Mohamed Eltabakh 1.
Chapter 7: Constraints and Triggers Foreign Keys Local and Global Constraints Triggers 1.
SCUHolliday - coen 1789–1 Schedule Today: u Constraints, assertions, triggers u Read Sections , 7.4. Next u Embedded SQL, JDBC. u Read Sections.
1 Database Design: DBS CB, 2 nd Edition SQL in a Server Environment: CLI & JDBC & Security Ch Ch. 9.6 – Ch 10.1.
1 Database Design: DBS CB, 2 nd Edition SQL in a Server Environment: Stored Procedure & Embedded SQL Ch. 9.3, 9.4.
1 Introduction to Database Systems, CS420 SQL Persistent Stored Modules (PSM) – Stored Procedure.
JDBC Statements The JDBC Statement, CallableStatement, and PreparedStatement interfaces define the methods and properties that enables to send SQL or PL/SQL.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
SQL in the real world 1. The Three-Tier Architecture of Database Applications browser network HTTP Web server Application server Database server database.
SQL in the real world 1. The SQL Client-Server Interactions SQL-clientSQL-server Environment SQL-agent Module Connection Session Current catalog and schema.
Database Design and Programming Jan Baumbach Adopted from previous slides of Peter Schneider-Kamp.
SCU Fall 2002JoAnne Holliday10–1 Schedule Today u Embedded SQL. u Read Sections 8.1, 8.5. Next u Transaction concepts, security u Read Sections 8.6 – 8.7.
1 Lecture 11 PL/SQL Slides from
Database: JDBC Overview
1st Semester, 2017 Sanghyun Park
SQL Environment.
Introduction to Database Systems, CS420
Database Design and Programming
CMSC-461 Database Management Systems
Database JDBC Overview CS Programming Languages for Web Applications
Database Design and Programming
CPSC-310 Database Systems
CPSC-310 Database Systems
Unit I-2.
Persistent Stored Modules (PSM) PL/SQL Embedded SQL
Database-Connection Libraries
Modification to Views Via Triggers
Presentation transcript:

SCU Fall 2002JoAnne Holliday10–1 Schedule Today u Triggers, Procedures, PL/SQL. u Read Sections , 8.1, 8.5. Next u Transaction concepts, security u Read Sections 8.6 – 8.7

SCU Fall 2002JoAnne Holliday10–2 SQL Triggers Some differences, including: 1. The Oracle restriction about not modifying the relation of the trigger or other relations linked to it by constraints is not present in SQL (but Oracle is real; SQL is paper). 2. The action in SQL is a list of (restricted) SQL statements, not a PL/SQL statement.

SCU Fall 2002JoAnne Holliday10–3 Procedures Stored database objects that use a PL/SQL statement in their body. Procedure Declarations CREATE OR REPLACE PROCEDURE ( ) AS BEGIN END;. run;

SCU Fall 2002JoAnne Holliday10–4 Embedding SQL in a Host Language The cursor area is an area for the results of select statements that result in multiple rows. The cursor pointer is a pointer to a row in the collection of rows retrieved by a SQL query. Example: From within a host language, find the names and account numbers of customers with more than the variable amt dollars in some account.

SCU Fall 2002JoAnne Holliday10–5 Embedding SQL First, declare a cursor and specify the query in SQL: EXEC SQL declare c cursor for select customer-name, account# from Depositor, Account where Depositor.account#=Account.account# andAccount.balance > :amt END-EXEC This defines the cursor c.

SCU Fall 2002JoAnne Holliday10–6 Embedded SQL The query is not done until you do an open, then the query is done and the result is put into the cursor area. (The result may be larger than the actual buffer that is allocated as cursor c. The system takes care of that.) EXEC SQL open c END-EXEC

SCU Fall 2002JoAnne Holliday10–7 Embedded SQL You can only look at a single row at a time. This is done with the fetch statement. If cn and an are variables in the host language, this will cause the values of one row in the result to be placed in the variables: EXEC SQL fetch c into :cn :an END-EXEC

SCU Fall 2002JoAnne Holliday10–8 Embedded SQL Repeated calls to fetch get successive rows in the query result. The close statement causes the database system to delete the temporary relation that holds the results of the query. EXEC SQL close c END-EXEC

SCU Fall 2002JoAnne Holliday10–9 Using Java and JDBC Start with a Connection object, unique to DBMS and installation (see web page). Method createStatement() returns an object of class Statement (if there is no argument) or PreparedStatement if there is an SQL statement as argument.

SCU Fall 2002JoAnne Holliday10–10 JDBC Statement stat1 = myCon.createStatement(); PreparedStatement stat2 = myCon.createStatement( "SELECT beer, price " + "FROM Sells" + "WHERE bar = 'Joe''s Bar'" ); myCon is a connection, stat1 is an “empty” statement object, and stat2 is a (prepared) statement object that has an SQL statement associated.

SCU Fall 2002JoAnne Holliday10–11 Executing Statements JDBC distinguishes queries (statements that return data) from updates (statements that only affect the database). Methods executeQuery() and executeUpdate() are used to execute these two kinds of SQL statements. u They must have an argument if applied to a Statement, never if applied to a PreparedStatement. When a query is executed, it returns an object of class ResultSet.

SCU Fall 2002JoAnne Holliday10–12 Example stat1.executeUpdate( "INSERT INTO Sells" + "VALUES('Brass Rail', 'Bud', 3.00)" ); ResultSet Menu = stat2.executeQuery();

SCU Fall 2002JoAnne Holliday10–13 Getting the Tuples of a ResultSet Method Next() applies to a ResultSet and moves a “cursor” to the next tuple in that set. u Apply Next() once to get to the first tuple.  Next() returns FALSE if there are no more tuples. While a given tuple is the current of the cursor, you can get its ith component by applying to a ResultSet a method of the form get X (i), where X is the name for the type of that component.

SCU Fall 2002JoAnne Holliday10–14 Example while(Menu.Next()) { theBeer = Menu.getString(1); thePrice = Menu.getFloat(2);... }