Chapter 9 SQL in a server environment

Size: px
Start display at page:

Download "Chapter 9 SQL in a server environment"

Transcription

1 Chapter 9 SQL in a server environment SQL in a Programming Environment embedded SQL persistent stored modules Database-Connection Libraries Call-level interface (CLI) JDBC PHP

2 SQL in Real Programs We have seen only how SQL is used at the generic query interface --- an environment where we sit at a terminal and ask queries of a database. Reality is almost always different: conventional programs interacting with SQL.

3 Options 1. SQL statements are embedded in a host language (e.g., C). 2. Code in a specialized language is stored in the database itself (e.g., PSM, PL/SQL). 3. Connection tools are used to allow a conventional language to access a database (e.g., CLI, JDBC, PHP/DB).

4 SQL in a Programming Environment Embedded SQL: add to a conventional programming language (C for example, we called host language ), certain statements that represent SQL operation. Host language+embedded SQL code?

5 System Implementation Host Language + Embedded SQL Preprocessing Host Language + Function calls Host-language compiler SQL library Object-code program How to identify SQL statements? How to move data between SQL and a conventional programming language? Mismatch problem exists?

6 How to recognize SQL statements (the Interface between SQL statements and programming language) Each embedded SQL statement introduced with EXEC SQL Shared variables : exchange data between SQL and a host language. When they are referred by a SQL statement, these shared variables are prefixed by a colon, but they appear without colon in hostlanguage statements. EXEC SQL BEGIN / END DECLARE SECTION to declare shared variables.

7 the Interface between SQL statements and programming language SQL define an array of characters SQLSTATE that is set every time the system is called. SQLSTATE connects the host-language program with the SQL execution system : no error 02000: could not be found

8 Implementations of SQLSTATE SQL defines an array of characters SQLSTATE that is set every time the system is called. Errors are signaled there Different systems use different way Oracle provides us with a header file sqlca.h that declares a communication area and defines macros to access it, such as NOT FOUND. Sybase provides SQLCA with sqlcode 0:success, <0: fail, 100: not found

9 Example: Find the price for a given beer at a given bar Sells (bar, beer, price) EXEC SQL BEGIN DECLARATION SECTION CHAR thebar[21], thebeer[21]; Float theprice; EXEC SQL END DECLARAE SECTION EXEC SQL SELECT price INTO :theprice FROM sells WHERE beer = :thebeer AND bar =:thebar;

10 Queries produce sets of tuples as a result, while none of the major host languages supports a set data type directly. So, cursors are used. A cursor declaration: EXEC SQL DECLARE <cursor> CURSOR FOR <query> A statement EXEC SQL OPEN<cursor> : the cursor is ready to retrieve the first tuple of the relation over which the cursor ranges. EXEC SQL FETCH FROM < cursor > INTO <list of variables> EXEC SQL CLOSE <cursor>: the cursor is no longer ranges over tuples of the relation.

11 Cursor Example Void worthranges() { int i,digits, counts[15]; EXEC SQL BEGIN DECLARE SECTION; int worth; char SQLSTATE[6]; EXEC SQL END DECLARE SECTION; EXEC SQL DECLARE execcursor CURSOR FOR SELECT networth FROM MovieExec; EXEC SQL OPEN execcursor; while (1) { EXEC SQL FETCH FROM execcursor INTO :worth; if (NO_MORE_TUPLES) BREAK; else.. } EXEC SQL CLOSE execcursor; }

12 More about cursor: The order in which tuples are fetched from the relation can be specified. The effect of changes to the relation that the cursor ranges over can be limited. The motion of the cursor through the list of tuples can be varied.

13 Modification by cursor With Where clause WHERE CURRENT OF followed by the name of the cursor. Define NO_MORE_TUPLES!(strc mp(sqlstate, )) e.g... EXEC SQL OPEN execcursor; while (1) { EXEC SQL FETCH FROM execcursor INTO :execname,:execaddr,:certno,:worth; if (NO_MORE_TUPLES) BREAK; IF (WORTH < 1000) EXEC SQL DELETE FROM MovieExec WHERE CURRENT OF execcursor; else.. EXEC SQL CLOSE execcursor;

14 Protecting against concurrent updates EXEC SQL DECLARE execcursor INSENSITIVE CURSOR FOR SELECT networth FROM MovieExec; The SQL system will guarantee that changes to relation MovieExec made between one opening and closing of execcursor will not affect the set of tuples fetched. Insensitive cursors could be expensive, systems spend a lot of time to manage data access.

15 Scrolling Cursors EXEC SQL DECLARE execcursor SCROLL CURSOR FOR MovieExec; The cursor may be used in a manner other than moving forward in the order of tuples. Follow FETCH by one of several options that tell where to find the desired tuple. Those options are NEXT, PRIOR, FIRST, LAST and so on.

16 Need for Dynamic SQL Most applications use specific queries and modification statements to interact with the database. The DBMS compiles EXEC SQL statements into specific procedure calls and produces an ordinary host-language program that uses a library. Sometimes we don t know what it needs to do until it runs?

17 Dynamic SQL Preparing a query: EXEC SQL PREPARE <query-name> FROM <text of the query>; Executing a query: EXEC SQL EXECUTE <query-name>; Prepare = optimize query. Prepare once, execute many times.

18 Example: A Generic Interface EXEC SQL BEGIN DECLARE SECTION; char query[max_length]; EXEC SQL END DECLARE SECTION; while(1) { /* issue SQL> prompt */ /* read user s query into array query */ EXEC SQL PREPARE q FROM :query; EXEC SQL EXECUTE q; } q is an SQL variable representing the optimized form of whatever statement is typed into :query

19 Execute-Immediate If we are only going to execute the query once, we can combine the PREPARE and EXECUTE steps into one. Use: EXEC SQL EXECUTE IMMEDIATE <text>;

20 Example: Generic Interface Again EXEC SQL BEGIN DECLARE SECTION; char query[max_length]; EXEC SQL END DECLARE SECTION; while(1) { /* issue SQL> prompt */ /* read user s query into array query */ EXEC SQL EXECUTE IMMEDIATE :query; }

21 Stored Procedures PSM, or persistent stored modules, allows us to store procedures as database schema elements. PSM = a mixture of conventional statements (if, while, etc.) and SQL. Lets us do things we cannot do in SQL alone.

22 Procedures Stored in the Schema Aim Provide a way for the user to store with a database schema some functions or procedures that can be used in SQL queries or other SQL statements.

23 Creating PSM Functions and Procedures Procedure Declarations CREATE PROCEDURE <name>(<arglist>) local declarations; procedure body; Function Declarations CREATE FUNCTION <name> (<parameters>) RETURNS <type> local declarations function body;

24 Example: CREATE PROCEDURE move ( IN oldaddr VARCHAR [255], IN newaddr VARCHAR [255] UPDATE MOVIEsTAR SET address = newaddr WHERE address = oldaddr; ) The parameters of a procedure are triples of mode-name-type IN = procedure uses value, does not change value. OUT = procedure changes, does not use. INOUT = both.

25 Function Declaration Function parameter may only be of mode IN, the only way to obtain information from a function is through its return-value.

26 Example: Stored Procedure Let s write a procedure that takes two arguments b and p, and adds a tuple to Sells that has bar = Joe s Bar, beer = b, and price = p. Used by Joe to add to his menu more easily.

27 The Procedure CREATE PROCEDURE JoeMenu ( ) IN b IN p CHAR(20), REAL INSERT INTO Sells VALUES( Joe s Bar, b, p); Parameters are both read-only, not changed The body --- a single insertion

28 Invoking Procedures Use SQL/PSM statement CALL, with the name of the desired procedure and arguments. Example: CALL JoeMenu( Moosedrool, 5.00);

29 Where to call? CALL <procedure name> (<argument list>); From a host-language program, e.g. EXEC SQL CALL foo(:x,3); As a statement of another PSM function or procedure As an SQL command issued to the generic SQL interface, e.g. CALL foo(1,3)

30 Invoking Functions It is not permitted to call a function. Use the function name and suitable arguments as part of an expression. Functions used in SQL expressions where a value of their return type is appropriate.

31 Simple statements in PSM Return statement in a function: RETURN <expression>; declare local variables : DECLARE <name><type>; Assignments: SET <variable>=<expression>; SET b = Bud ; Groups of statements: BEGIN END Separate by semicolons. Branching statements: If then else, Loops: for-loops, loops,

32 Example: IF Let s rate bars by how many customers they have, based on Frequents(drinker, bar). <100 customers: unpopular customers: average. >= 200 customers: popular. Function Rate(b) rates bar b.

33 Example: IF (continued) CREATE FUNCTION Rate (IN b CHAR(20) ) BEGIN END; RETURNS CHAR(10) DECLARE cust INTEGER; SET cust = (SELECT COUNT(*) FROM Frequents WHERE bar = b); IF cust < 100 THEN RETURN unpopular ELSEIF cust < 200 THEN RETURN average ELSE RETURN popular END IF; Number of customers of bar b Nested IF statement

34 Loops Basic form: <loop name>: LOOP <statements> END LOOP; Exit from a loop by: LEAVE <loop name>

35 Example: Exiting a Loop loop1: LOOP... LEAVE loop1;... END LOOP; If this statement is executed... Control winds up here

36 Other Loop Forms WHILE <condition> DO <statements> END WHILE; REPEAT <statements> UNTIL <condition> END REPEAT;

37 Queries General SELECT-FROM-WHERE queries are not permitted in PSM. There are three ways to get the effect of a query: 1. Queries producing one value can be the expression in an assignment. 2. Single-row SELECT... INTO. 3. Cursors.

38 Example: Assignment/Query Using local variable p and Sells(bar, beer, price), we can get the price Joe charges for Bud by: SET p = (SELECT price FROM Sells WHERE bar = Joe s Bar AND beer = Bud );

39 SELECT... INTO Another way to get the value of a query that returns one tuple is by placing INTO <variable> after the SELECT clause. Example: SELECT price INTO p FROM Sells WHERE bar = Joe s Bar AND beer = Bud ;

40 Cursors A cursor is essentially a tuple-variable that ranges over all tuples in the result of some query. Declare a cursor c by: DECLARE c CURSOR FOR <query>;

41 Opening and Closing Cursors To use cursor c, we must issue the command: OPEN c; The query of c is evaluated, and c is set to point to the first tuple of the result. When finished with c, issue command: CLOSE c;

42 Fetching Tuples From a Cursor To get the next tuple from cursor c, issue command: FETCH FROM c INTO x1, x2,,xn ; The x s are a list of variables, one for each component of the tuples referred to by c. c is moved automatically to the next tuple.

43 Breaking Cursor Loops (1) The usual way to use a cursor is to create a loop with a FETCH statement, and do something with each tuple fetched. A tricky point is how we get out of the loop when the cursor has no more tuples to deliver.

44 Breaking Cursor Loops (2) Each SQL operation returns a status, which is a 5-digit character string. For example, = Everything OK, and = Failed to find a tuple. In PSM, we can get the value of the status in a variable called SQLSTATE.

45 Breaking Cursor Loops (3) We may declare a condition, which is a boolean variable that is true if and only if SQLSTATE has a particular value. Example: We can declare condition NotFound to represent by: DECLARE NotFound CONDITION FOR SQLSTATE ;

46 Breaking Cursor Loops (4) The structure of a cursor loop is thus: cursorloop: LOOP FETCH c INTO ; IF NotFound THEN LEAVE cursorloop; END IF; END LOOP;

47 Exceptions in PSM Where to go: 1) continue:execute the CREATE FUNCTION GetYear(t statement VARCHAR[255]) after the one that RETURNS INTEGER raised the exception. DECLARE Not_Found 2) CONDITION Exit:leave the FOR BEGIN END SQLSTATE block.the statement after the ; block is executed next. DECLARE Too_Mamy 3) CONDITION Undo: not executed FOR SQLSTATE the ; statement within the block and exit like 2) BEGIN DECLARE EXIT HANDLER FOR Not_Found,Too_Many RETURN NULL;// handler declaration RETURN (SELECT year FROM Movie WHERE title=t); END;

48 Components of Exception handler in PSM A list of exception conditions that invoke the handler when raised. Code to be executed when one of the associated exceptions is raised. An indication of where to go after the handler has finished its work. DELARE <where to go> HANDLER FOR <condition list> <statement>

49 Example: Cursor in PSM Let s write a procedure that examines Sells(bar, beer, price), and raises by $1 the price of all beers at Joe s Bar that are under $3. Yes, we could write this as a simple UPDATE, but the details are instructive anyway.

50 The Needed Declarations CREATE PROCEDURE JoeGouge( ) DECLARE thebeer CHAR(20); DECLARE theprice REAL; DECLARE NotFound CONDITION FOR SQLSTATE ; DECLARE c CURSOR FOR (SELECT beer, price FROM Sells WHERE bar = Joe s Bar ); Used to hold beer-price pairs when fetching through cursor c Returns Joe s menu

51 The Procedure Body BEGIN OPEN c; menuloop: LOOP FETCH c INTO thebeer, theprice; IF NotFound THEN LEAVE menuloop END IF; IF theprice < 3.00 THEN UPDATE Sells SET price = theprice+1.00 WHERE bar = Joe s Bar AND beer = thebeer; END IF; END LOOP; CLOSE c; END; Check if the recent FETCH failed to get a tuple If Joe charges less than $3 for the beer, raise it s price at Joe s Bar by $1.

52 Database connection The third approach to connecting databases to conventional languages is to use library calls. 1. C + CLI 2. Java + JDBC 3. PHP + PEAR/DB

53 Three-Tier Architecture A common environment for using a database has three tiers of processors: 1. Web servers --- talk to the user. 2. Application servers --- execute the business logic. 3. Database servers --- get what the app servers need from the database.

54 DBMS environment: the framework under which data may exist and SQL operation on data may be executed. catalog schema catalog cluster catalog environment Schemas: collections of tables, views, assertions, domains and so on. Catalog: collections of schemas, information about all the schemas in the catalog. Clusters: each user has an associated cluster, so in a sense, a cluster is the database as seen by a particular user.

55 Environments, Connections, Queries The database is, in many DB-access languages, an environment. Database servers maintain some number of connections, so app servers can ask queries or perform modifications. The app server issues statements : queries and modifications, usually.

56 Diagram to Remember Environment Connection Statement

57 SQL/CLI Instead of using a preprocessor (as in embedded SQL), we can use a library of functions. The library for C is called SQL/CLI = Call- Level Interface. Embedded SQL s preprocessor will translate the EXEC SQL statements into CLI or similar calls, anyway.

58 Data Structures C connects to the database by structs of the following types: 1. Environments : represent the DBMS installation. 2. Connections : logins to the database. 3. Statements : SQL statements to be passed to a connection. 4. Descriptions : records about tuples from a query, or parameters of a statement.

59 JDBC Java Database Connectivity (JDBC) is a library similar to SQL/CLI, but with Java as the host language. Like CLI, but with a few differences for us to cover.

60 Making a Connection import java.sql.*; The JDBC classes Class.forName(com.mysql.jdbc.Driver); Connection mycon = DriverManager.getConnection( ); Loaded by forname URL of the database, your name, and password go here. The driver for mysql; others exist

61 Statements JDBC provides two classes: 1. Statement = an object that can accept a string that is a SQL statement and can execute such a string. 2. PreparedStatement = an object that has an associated SQL statement ready to execute.

62 Creating Statements The Connection class has methods to create Statements and PreparedStatements. Statement stat1 = mycon.createstatement(); PreparedStatement stat2 = mycon.createstatement( SELECT beer, price FROM Sells + WHERE bar = Joe s Bar ); createstatement with no argument returns a Statement; with one argument it returns a PreparedStatement.

63 Executing SQL Statements JDBC distinguishes queries from modifications, which it calls updates. Statement and PreparedStatement each have methods executequery and executeupdate. For Statements: one argument (the query or modification to be executed). For PreparedStatements: no argument.

64 Example: Update stat1 is a Statement. We can use it to insert a tuple as: stat1.executeupdate( ); INSERT INTO Sells + VALUES( Brass Rail, Bud,3.00)

65 Example: Query stat2 is a PreparedStatement holding the query SELECT beer, price FROM Sells WHERE bar = Joe s Bar. executequery returns an object of class ResultSet we ll examine it later. The query: ResultSet menu = stat2.executequery();

66 Accessing the ResultSet An object of type ResultSet is something like a cursor. Method next() advances the cursor to the next tuple. The first time next() is applied, it gets the first tuple. If there are no more tuples, next() returns the value false.

67 Accessing Components of Tuples When a ResultSet is referring to a tuple, we can get the components of that tuple by applying certain methods to the ResultSet. Method getx (i ), where X is some type, and i is the component number, returns the value of that component. The value must have type X.

68 Example: Accessing Components Menu = ResultSet for query SELECT beer, price FROM Sells WHERE bar = Joe s Bar. Access beer and price from each tuple by: while ( menu.next() ) { } thebeer = Menu.getString(1); theprice = Menu.getFloat(2); /*something with thebeer and theprice*/

69 PHP (personal home page) A scripting language to be used for actions within HTML text. Indicated by <? PHP code?>. DB library exists within PEAR (PHP Extension and Application Repository). Include with include(db.php).

70 Variables in PHP Must begin with $. OK not to declare a type for a variable. But you give a variable a value that belongs to a class, in which case, methods of that class are available to it.

71 String Values PHP solves a very important problem for languages that commonly construct strings as values: How do I tell whether a substring needs to be interpreted as a variable and replaced by its value? PHP solution: Double quotes means replace; single quotes means don t.

72 Example: Replace or Not? $100 = one hundred dollars ; $sue = You owe me $100. ; $joe = You owe me $100. ; Value of $sue is You owe me $100, while the value of $joe is You owe me one hundred dollars.

73 PHP Arrays Two kinds: numeric and associative. Numeric arrays are ordinary, indexed 0,1, Example: $a = array( Paul, George, John, Ringo ); Then $a[0] is Paul, $a[1] is George, and so on.

74 Associative Arrays Elements of an associative array $a are pairs x => y, where x is a key string and y is any value. If x => y is an element of $a, then $a[x] is y.

75 Example: Associative Arrays An environment can be expressed as an associative array, e.g.: $myenv = array( phptype => oracle, hostspec => database => cs145db, username => ullman, password => notmypw );

76 Making a Connection With the DB library imported and the array $myenv available: include(db.php); $mycon = DB::connect($myEnv); Function connect in the DB library Class is Connection because it is returned by DB::connect(). <vendor>://<user name>:<password><host name>/<database name>

77 Executing SQL Statements Method query applies to a Connection object. It takes a string argument and returns a result. Could be an error code or the relation returned by a query.

78 Remember this variable is replaced by its value. Example: Executing a Query Find all the bars that sell a beer given by the variable $beer. Method application $beer = Bud ; $result = $mycon->query( SELECT bar FROM Sells. WHERE beer = $beer ; ); Concatenatio in PHP

79 Cursors in PHP The result of a query is the tuples returned. Method fetchrow applies to the result and returns the next tuple, or FALSE if there is none.

80 Example: Cursors while ($bar = $result->fetchrow()) { // do something with $bar }

81 Summary Embedded SQL (shared variables, EXEC SQL, Cursor), Dynamic SQL SQL/PSM Call-level Interface (SQL/CLI) JDBC PHP

Chapter 9 SQL in a server environment

Chapter 9 SQL in a server environment Chapter 9 SQL in a server environment SQL in a Programming Environment embedded SQL persistent stored modules Database-Connection Libraries Call-level interface (CLI) JDBC PHP Database connection The third

More information

Real SQL Programming 1

Real SQL Programming 1 Real SQL Programming 1 SQL in Real Programs We have seen only how SQL is used at the generic query interface an environment where we sit at a terminal and ask queries of a database Reality is almost always

More information

Database-Connection Libraries. Java Database Connectivity PHP

Database-Connection Libraries. Java Database Connectivity PHP Database-Connection Libraries Call-Level Interface Java Database Connectivity PHP 1 An Aside: SQL Injection SQL queries are often constructed by programs. These queries may take constants from user input.

More information

Database-Connection Libraries

Database-Connection Libraries Database-Connection Libraries CALL-LEVEL INTERFACE JAVA DATABASE CONNECTIVITY PHP PEAR/DB 1 An Aside: SQL Injection SQL queries are often constructed by programs. These queries may take constants from

More information

Databases 1. SQL/PSM and Oracle PL/SQL

Databases 1. SQL/PSM and Oracle PL/SQL Databases 1 SQL/PSM and Oracle PL/SQL SQL DDL (Data Definition Language) Defining a Database Schema Primary Keys, Foreign Keys Local and Global Constraints Defining Views Triggers 2 SQL DML (Database Modifications)

More information

Real SQL Programming Persistent Stored Modules (PSM)

Real SQL Programming Persistent Stored Modules (PSM) Real SQL Programming Persistent Stored Modules (PSM) Ullman-Widom: Adatbázisrendszerek Alapvetés. Második, átdolgozott kiadás, Panem, 2009 9.3. Az SQL és a befogadó nyelv közötti felület (sormutatók, cursors)

More information

Schedule. Feb. 12 (T) Advising Day. No class. Reminder: Midterm is Feb. 14 (TH) Today: Feb. 7 (TH) Feb. 21 (TH) Feb. 19 (T)

Schedule. Feb. 12 (T) Advising Day. No class. Reminder: Midterm is Feb. 14 (TH) Today: Feb. 7 (TH) Feb. 21 (TH) Feb. 19 (T) Schedule Today: Feb. 7 (TH) PL/SQL, Embedded SQL, CLI, JDBC. Read Sections 8.1, 8.3-8.5. Feb. 12 (T) Advising Day. No class. Reminder: Midterm is Feb. 14 (TH) Covers material through Feb. 7 (TH) lecture

More information

CSCD43: Database Systems Technology. Lecture 4

CSCD43: Database Systems Technology. Lecture 4 CSCD43: Database Systems Technology Lecture 4 Wael Aboulsaadat Acknowledgment: these slides are based on Prof. Garcia-Molina & Prof. Ullman slides accompanying the course s textbook. Steps in Database

More information

Options. Real SQL Programming 1. Stored Procedures. Embedded SQL

Options. Real SQL Programming 1. Stored Procedures. Embedded SQL Real 1 Options We have seen only how SQL is used at the generic query interface an environment where we sit at a terminal and ask queries of a database. Reality is almost always different: conventional

More information

Non-interactive SQL. EECS Introduction to Database Management Systems

Non-interactive SQL. EECS Introduction to Database Management Systems Non-interactive SQL EECS3421 - Introduction to Database Management Systems Using a Database Interactive SQL: Statements typed in from terminal; DBMS outputs to screen. Interactive SQL is inadequate in

More information

Database Applications. SQL/PSM Embedded SQL JDBC

Database Applications. SQL/PSM Embedded SQL JDBC Database Applications SQL/PSM Embedded SQL JDBC 1 Course Objectives Design Construction Applications Usage 2 Course Objectives Interfacing When the course is through, you should Know how to connect to

More information

Outline. CS 235: Introduction to Databases. DB Application Programming. Interface Solutions. Basic PSM Form. Persistent Stored Modules

Outline. CS 235: Introduction to Databases. DB Application Programming. Interface Solutions. Basic PSM Form. Persistent Stored Modules Outline CS 235: Introduction to Databases Svetlozar Nestorov Database application programming SQL limitations SQL Persistent, Stored Modules (PSM) Extension of SQL PL/SQL: Oracle s version of PSM Lecture

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Chapter 10 Outline Database Programming: Techniques and Issues Embedded SQL, Dynamic SQL, and SQLJ Database Programming with Function Calls: SQL/CLI and JDBC Database Stored Procedures and SQL/PSM Comparing

More information

EMBEDDED SQL. SE 3DB3 Fall 2016 MICHAEL LIUT DEPARTMENT OF COMPUTING AND SOFTWARE MCMASTER UNIVERSITY

EMBEDDED SQL. SE 3DB3 Fall 2016 MICHAEL LIUT DEPARTMENT OF COMPUTING AND SOFTWARE MCMASTER UNIVERSITY EMBEDDED SQL MICHAEL LIUT (LIUTM@MCMASTER.CA) DEPARTMENT OF COMPUTING AND SOFTWARE MCMASTER UNIVERSITY SE 3DB3 Fall 2016 (Slides adapted from Dr. Fei Chiang, Diane Horton, examples from J. Ullman, J. Widom)

More information

Embedded SQL. csc343, Introduction to Databases Diane Horton with examples from Ullman and Widom Fall 2014

Embedded SQL. csc343, Introduction to Databases Diane Horton with examples from Ullman and Widom Fall 2014 Embedded SQL csc343, Introduction to Databases Diane Horton with examples from Ullman and Widom Fall 2014 Problems with using interactive SQL Standard SQL is not Turing-complete. E.g., Two profs are colleagues

More information

Chapter 13 Introduction to SQL Programming Techniques

Chapter 13 Introduction to SQL Programming Techniques Chapter 13 Introduction to SQL Programming Techniques Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 Outline Database Programming: Techniques and Issues Embedded

More information

SQL in Programming Languages Read chapter 5 of Atzeni et al. BD: Modelli e Linguaggi di Interrogazione and section 8.

SQL in Programming Languages Read chapter 5 of Atzeni et al. BD: Modelli e Linguaggi di Interrogazione and section 8. SQL in Programming Languages Read chapter 5 of Atzeni et al. BD: Modelli e Linguaggi di Interrogazione and section 8.4 of Garcia-Molina Slides derived from those by Jeffrey D. Ullman SQL and Programming

More information

DATABASE DESIGN - 1DL400

DATABASE DESIGN - 1DL400 DATABASE DESIGN - 1DL400 Fall 2015 A course on modern database systems http://www.it.uu.se/research/group/udbl/kurser/dbii_ht15 Kjell Orsborn Uppsala Database Laboratory Department of Information Technology,

More information

Embedded SQL. csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Meraji Winter 2018

Embedded SQL. csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Meraji Winter 2018 Embedded SQL csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Meraji Winter 2018 Problems with using interactive SQL Standard SQL is not Turing-complete. E.g., Two profs

More information

Database Design and Programming

Database Design and Programming Database Design and Programming Jan Baumbach jan.baumbach@imada.sdu.dk http://www.baumbachlab.net JDBC Java Database Connectivity (JDBC) is a library similar for accessing a DBMS with Java as the host

More information

Assign expressions to declared variables with :=. END IF; EXIT WHEN éconditioné END LOOP;

Assign expressions to declared variables with :=. END IF; EXIT WHEN éconditioné END LOOP; Assignment Assign expressions to declared variables with :=. Branches IF éconditioné THEN éstatementèsèé ELSE éstatementèsèé END IF; But in nests, use ELSIF in place of ELSE IF. Loops LOOP... EXIT WHEN

More information

ITCS Implementation. Jing Yang 2010 Fall. Class 14: Introduction to SQL Programming Techniques (Ch13) Outline

ITCS Implementation. Jing Yang 2010 Fall. Class 14: Introduction to SQL Programming Techniques (Ch13) Outline ITCS 3160 Data Base Design and Implementation Jing Yang 2010 Fall Class 14: Introduction to SQL Programming Techniques (Ch13) Outline Database Programming: Techniques and Issues Three approaches: Embedded

More information

PL/SQL, Embedded SQL. Lecture #14 Autumn, Fall, 2001, LRX

PL/SQL, Embedded SQL. Lecture #14 Autumn, Fall, 2001, LRX PL/SQL, Embedded SQL Lecture #14 Autumn, 2001 Fa, 2001, LRX #14 PL/SQL,Embedded SQL HUST,Wuhan,China 402 PL/SQL Found ony in the Orace SQL processor (sqpus). A compromise between competey procedura programming

More information

Likesèdrinker, beerè. Sellsèbar, beer, priceè. Frequentsèdrinker, barè

Likesèdrinker, beerè. Sellsèbar, beer, priceè. Frequentsèdrinker, barè Modication to Views Via Triggers Oracle allows us to ëintercept" a modication to a view through an instead-of trigger Example Likesèdrinker, beerè Sellsèbar, beer, priceè Frequentsèdrinker, barè CREATE

More information

Working with Databases and Java

Working with Databases and Java Working with Databases and Java Pedro Contreras Department of Computer Science Royal Holloway, University of London January 30, 2008 Outline Introduction to relational databases Introduction to Structured

More information

JDBC, Transactions. Niklas Fors JDBC 1 / 38

JDBC, Transactions. Niklas Fors JDBC 1 / 38 JDBC, Transactions SQL in Programs Embedded SQL and Dynamic SQL JDBC Drivers, Connections, Statements, Prepared Statements Updates, Queries, Result Sets Transactions Niklas Fors (niklas.fors@cs.lth.se)

More information

Ghislain Fourny. Information Systems for Engineers 7. The ecosystem around SQL

Ghislain Fourny. Information Systems for Engineers 7. The ecosystem around SQL Ghislain Fourny Information Systems for Engineers 7. The ecosystem around SQL How do we use databases? How do we use databases? Simple database installed on a machine (MySQL, PostgreSQL...). User inserts

More information

Database Programming. Week 9. *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford

Database Programming. Week 9. *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford Database Programming Week 9 *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford SQL in Real Programs We have seen only how SQL is used at the generic query interface

More information

Overview. Database Application Development. SQL in Application Code. SQL in Application Code (cont.)

Overview. Database Application Development. SQL in Application Code. SQL in Application Code (cont.) Overview Database Application Development Chapter 6 Concepts covered in this lecture: SQL in application code Embedded SQL Cursors Dynamic SQL JDBC SQLJ Stored procedures Database Management Systems 3ed

More information

Database Application Development

Database Application Development Database Application Development Chapter 6 Database Management Systems 3ed 1 Overview Concepts covered in this lecture: SQL in application code Embedded SQL Cursors Dynamic SQL JDBC SQLJ Stored procedures

More information

Database Application Development

Database Application Development Database Application Development Chapter 6 Database Management Systems 3ed 1 Overview Concepts covered in this lecture: SQL in application code Embedded SQL Cursors Dynamic SQL JDBC SQLJ Stored procedures

More information

Database Application Development

Database Application Development Database Application Development Linda Wu (CMPT 354 2004-2) Topics SQL in application code Embedded SQL JDBC SQLJ Stored procedures Chapter 6 CMPT 354 2004-2 2 SQL in Application Code SQL commands can

More information

SQL Stored Programs. You Can Not Do Everything in SQL SQL/PSM Cursors Recursion Triggers. Niklas Fors Stored Programs 1 / 21

SQL Stored Programs. You Can Not Do Everything in SQL SQL/PSM Cursors Recursion Triggers. Niklas Fors Stored Programs 1 / 21 SQL Stored Programs You Can Not Do Everything in SQL SQL/PSM Cursors Recursion Triggers Niklas Fors (niklas.fors@cs.lth.se) Stored Programs 1 / 21 Stored Programs SQL is not Turing complete so there are

More information

Database Management

Database Management Database Management - 2013 Model Answers 1. a. A cyclic relationship type (also called recursive) is a relationship type between two occurrences of the same entity type. With each entity type in a cyclic

More information

1. Given the name of a movie studio, find the net worth of its president.

1. Given the name of a movie studio, find the net worth of its president. 1. Given the name of a movie studio, find the net worth of its president. CREATE FUNCTION GetNetWorth( studio VARCHAR(30) ) RETURNS DECIMAL(9,3) DECLARE worth DECIMAL(9,3); SELECT networth INTO worth FROM

More information

Database Application Development

Database Application Development Database Application Development Chapter 6 PSM (Stored Procedures) 1 Stored Procedures What is a stored procedure: SQL allows you to define procedures and functions and store in the DB server Program executed

More information

Database and MySQL Temasek Polytechnic

Database and MySQL Temasek Polytechnic PHP5 Database and MySQL Temasek Polytechnic Database Lightning Fast Intro Database Management Organizing information using computer as the primary storage device Database The place where data are stored

More information

Introduction to SQL SELECT-FROM-WHERE STATEMENTS SUBQUERIES DATABASE SYSTEMS AND CONCEPTS, CSCI 3030U, UOIT, COURSE INSTRUCTOR: JAREK SZLICHTA

Introduction to SQL SELECT-FROM-WHERE STATEMENTS SUBQUERIES DATABASE SYSTEMS AND CONCEPTS, CSCI 3030U, UOIT, COURSE INSTRUCTOR: JAREK SZLICHTA Introduction to SQL SELECT-FROM-WHERE STATEMENTS MULTIRELATION QUERIES SUBQUERIES 1 SQL SQL is a standard language for accessing databases. SQL stands for Structured Query Language. SQL lecture s material

More information

Cyrus Shahabi Computer Science Department University of Southern California C. Shahabi

Cyrus Shahabi Computer Science Department University of Southern California C. Shahabi Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California shahabi@usc.edu 1 Overview JDBC Package Connecting to databases with JDBC Executing

More information

Application Programming for Relational Databases

Application Programming for Relational Databases Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California shahabi@usc.edu 1 Overview JDBC Package Connecting to databases with JDBC Executing

More information

SQL from Applications

SQL from Applications SQL from Applications UVic C SC 370 Dr. Daniel M. German Department of Computer Science June 4, 2003 Version: 1.1.0 6 1 SQL from Applications (1.1.0) CSC 370 dmgerman@uvic.ca Overview Embedded SQL JDBC

More information

Overview. SQL from Applications. Accesing data from an application. Embedded SQL JDBC Stored Procedures. UVic C SC 370, Fall 2002

Overview. SQL from Applications. Accesing data from an application. Embedded SQL JDBC Stored Procedures. UVic C SC 370, Fall 2002 SQL from Applications UVic C SC 370, Fall 2002 Embedded SQL JDBC Stored Procedures Overview Daniel M. German Department of Computer Science University of Victoria October 15, 2002 Version: 1.00 6 1 SQL

More information

SQL: Programming Midterm in class next Thursday (October 5)

SQL: Programming Midterm in class next Thursday (October 5) Announcements (September 28) 2 Homework #1 graded Homework #2 due today Solution available this weekend SQL: Programming Midterm in class next Thursday (October 5) Open book, open notes Format similar

More information

Discuss setting up JDBC connectivity. Demonstrate a JDBC program Discuss and demonstrate methods associated with JDBC connectivity

Discuss setting up JDBC connectivity. Demonstrate a JDBC program Discuss and demonstrate methods associated with JDBC connectivity Objectives Discuss setting up JDBC connectivity. Demonstrate a JDBC program Discuss and demonstrate methods associated with JDBC connectivity Setting Up JDBC Before you can begin to utilize JDBC, you must

More information

CSCI/CMPE Object-Oriented Programming in Java JDBC. Dongchul Kim. Department of Computer Science University of Texas Rio Grande Valley

CSCI/CMPE Object-Oriented Programming in Java JDBC. Dongchul Kim. Department of Computer Science University of Texas Rio Grande Valley CSCI/CMPE 3326 Object-Oriented Programming in Java JDBC Dongchul Kim Department of Computer Science University of Texas Rio Grande Valley Introduction to Database Management Systems Storing data in traditional

More information

Introduction to SQL. Select-From-Where Statements Multirelation Queries Subqueries. Slides are reused by the approval of Jeffrey Ullman s

Introduction to SQL. Select-From-Where Statements Multirelation Queries Subqueries. Slides are reused by the approval of Jeffrey Ullman s Introduction to SQL Select-From-Where Statements Multirelation Queries Subqueries Slides are reused by the approval of Jeffrey Ullman s 1 Why SQL? SQL is a very-high-level language. Say what to do rather

More information

SQL in a Server Environment

SQL in a Server Environment ICS 321 Fall 2011 SQL in a Server Environment Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 11/02/2011 Lipyeow Lim -- University of Hawaii at Manoa 1 Three

More information

Database Application Development

Database Application Development Database Application Development Chapter 6 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Overview Concepts covered in this lecture: SQL in application code Embedded SQL Cursors Dynamic

More information

SQL: Programming. Announcements (September 25) Motivation. CPS 116 Introduction to Database Systems. Pros and cons of SQL.

SQL: Programming. Announcements (September 25) Motivation. CPS 116 Introduction to Database Systems. Pros and cons of SQL. SQL: Programming CPS 116 Introduction to Database Systems Announcements (September 25) 2 Homework #2 due this Thursday Submit to Yi not through Jun s office door Solution available this weekend No class

More information

Embedded SQL. Introduction

Embedded SQL. Introduction Embedded SQL Davood Rafiei 1 Introduction Basic Idea: Use SQL statements inside a host language (C, C++, Java, ). Advantages: Can do all the fancy things you do in C/C++/Java. Still have the power of SQL.

More information

Embedded SQL. Davood Rafiei

Embedded SQL. Davood Rafiei Embedded SQL Davood Rafiei 1 Introduction Basic Idea: Use SQL statements inside a host language (C, C++, Java, ). Advantages: Can do all the fancy things you do in C/C++/Java. Still have the power of SQL.

More information

CS54100: Database Systems

CS54100: Database Systems CS54100: Database Systems SQL DDL 27 January 2012 Prof. Chris Clifton Defining a Database Schema CREATE TABLE name (list of elements). Principal elements are attributes and their types, but key declarations

More information

SQL DATA DEFINITION LANGUAGE

SQL DATA DEFINITION LANGUAGE SQL DATA DEFINITION LANGUAGE DATABASE SCHEMAS IN SQL SQL is primarily a query language, for getting information from a database. DML: Data Manipulation Language SFWR ENG 3DB3 FALL 2016 MICHAEL LIUT (LIUTM@MCMASTER.CA)

More information

13 Creation and Manipulation of Tables and Databases

13 Creation and Manipulation of Tables and Databases 150.420 Informationslogistik SQL Handout No. 9 SS 2013 13 Creation and Manipulation of Tables and Databases 13.1 Creation and Deletion Databases can be created and deleted using respectively. CREATE DATABASE

More information

Databases 1. Defining Tables, Constraints

Databases 1. Defining Tables, Constraints Databases 1 Defining Tables, Constraints DBMS 2 Rest of SQL Defining a Database Schema Primary Keys, Foreign Keys Local and Global Constraints Defining Views Triggers 3 Defining a Database Schema A database

More information

SQL: Data Definition Language

SQL: Data Definition Language SQL: Data Definition Language CSC 343 Winter 2018 MICHAEL LIUT (MICHAEL.LIUT@UTORONTO.CA) DEPARTMENT OF MATHEMATICAL AND COMPUTATIONAL SCIENCES UNIVERSITY OF TORONTO MISSISSAUGA Database Schemas in SQL

More information

Databases-1 Lecture-01. Introduction, Relational Algebra

Databases-1 Lecture-01. Introduction, Relational Algebra Databases-1 Lecture-01 Introduction, Relational Algebra Information, 2018 Spring About me: Hajas Csilla, Mathematician, PhD, Senior lecturer, Dept. of Information Systems, Eötvös Loránd University of Budapest

More information

Announcements. SQL: Part IV. Transactions. Summary of SQL features covered so far. Fine prints. SQL transactions. Reading assignments for this week

Announcements. SQL: Part IV. Transactions. Summary of SQL features covered so far. Fine prints. SQL transactions. Reading assignments for this week Announcements 2 SQL: Part IV CPS 216 Advanced Database Systems Reading assignments for this week A Critique of ANSI SQL Isolation Levels, by Berenson et al. in SIGMOD 1995 Weaving Relations for Cache Performance,

More information

Contains slides made by Naci Akkøk, Pål Halvorsen, Arthur M. Keller, Vera Goebel

Contains slides made by Naci Akkøk, Pål Halvorsen, Arthur M. Keller, Vera Goebel SQL-99 Contains slides made by Naci Akkøk, Pål Halvorsen, Arthur M. Keller, Vera Goebel SQL-99 user-defined types (UDTs) methods for UDTs declarations references operations Overview 2 SQL Development SQL-86

More information

Chapter 6 The database Language SQL as a tutorial

Chapter 6 The database Language SQL as a tutorial Chapter 6 The database Language SQL as a tutorial About SQL SQL is a standard database language, adopted by many commercial systems. ANSI SQL, SQL-92 or SQL2, SQL99 or SQL3 extends SQL2 with objectrelational

More information

Lab # 9. Java to Database Connection

Lab # 9. Java to Database Connection Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Lab # 9 Java to Database Connection Eng. Haneen El-Masry December, 2014 2 Objective In this lab, we turn

More information

Running SQL in Java and PHP

Running SQL in Java and PHP Running SQL in Java and PHP FCDB 9.6 9.7 Dr. Chris Mayfield Department of Computer Science James Madison University Mar 01, 2017 Introduction to JDBC JDBC = Java Database Connectivity 1. Connect to the

More information

Lesson 13 Transcript: User-Defined Functions

Lesson 13 Transcript: User-Defined Functions Lesson 13 Transcript: User-Defined Functions Slide 1: Cover Welcome to Lesson 13 of DB2 ON CAMPUS LECTURE SERIES. Today, we are going to talk about User-defined Functions. My name is Raul Chong, and I'm

More information

SQL DATA DEFINITION LANGUAGE

SQL DATA DEFINITION LANGUAGE SQL DATA DEFINITION LANGUAGE DATABASE SCHEMAS IN SQL SQL is primarily a query language, for getting information from a database. DML: Data Manipulation Language SFWR ENG 3DB3 FALL 2016 MICHAEL LIUT (LIUTM@MCMASTER.CA)

More information

Database Application Development

Database Application Development CS 461: Database Systems Database Application Development supplementary material: Database Management Systems Sec. 6.2, 6.3 DBUtils.java, Student.java, Registrar.java, RegistrarServlet.java, PgRegistrar.sql

More information

A tuple is dangling if it doesn't join with any

A tuple is dangling if it doesn't join with any Outerjoin R./ S = R./Swith dangling tuples padded with nulls and included in the result. A tuple is dangling if it doesn't join with any other tuple. R = A B 1 2 3 4 S = B C 2 5 2 6 7 8 R./ S = A B C 1

More information

SQL STORED ROUTINES. CS121: Relational Databases Fall 2017 Lecture 9

SQL STORED ROUTINES. CS121: Relational Databases Fall 2017 Lecture 9 SQL STORED ROUTINES CS121: Relational Databases Fall 2017 Lecture 9 SQL Functions 2 SQL queries can use sophisticated math operations and functions Can compute simple functions, aggregates Can compute

More information

Chapter 2 The relational Model of data. Relational model introduction

Chapter 2 The relational Model of data. Relational model introduction Chapter 2 The relational Model of data Relational model introduction 1 Contents What is a data model? Basics of the relational model Next : How to define? How to query? Constraints on relations 2 What

More information

SQL DATA DEFINITION LANGUAGE

SQL DATA DEFINITION LANGUAGE 9/27/16 DATABASE SCHEMAS IN SQL SQL DATA DEFINITION LANGUAGE SQL is primarily a query language, for getting information from a database. SFWR ENG 3DB3 FALL 2016 But SQL also includes a data-definition

More information

Chapter 16: Databases

Chapter 16: Databases Chapter 16: Databases Starting Out with Java: From Control Structures through Objects Fifth Edition by Tony Gaddis Chapter Topics Chapter 16 discusses the following main topics: Introduction to Database

More information

IBM -

IBM - 6.1 6.2 6.3 6.4 2 6.1 q 6.1.1 SQL 3 q 6.1.2 Ø q Ø Ø Ø call level interface q Ø Web 4 6.1 6.2 6.3 6.4 5 6.2 q 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 SQL 6 6.2.1 q q Ø Ø Ø Ø 7 6.2.2 q q CONNECT TO < > < > < > [AS

More information

Database Applications

Database Applications Database Applications Database Programming Application Architecture Objects and Relational Databases John Edgar 2 Users do not usually interact directly with a database via the DBMS The DBMS provides

More information

CGS 3066: Spring 2017 SQL Reference

CGS 3066: Spring 2017 SQL Reference CGS 3066: Spring 2017 SQL Reference Can also be used as a study guide. Only covers topics discussed in class. This is by no means a complete guide to SQL. Database accounts are being set up for all students

More information

PHP: Hypertext Preprocessor. A tutorial Introduction

PHP: Hypertext Preprocessor. A tutorial Introduction PHP: Hypertext Preprocessor A tutorial Introduction Introduction PHP is a server side scripting language Primarily used for generating dynamic web pages and providing rich web services PHP5 is also evolving

More information

INTRODUCTION TO JDBC - Revised spring

INTRODUCTION TO JDBC - Revised spring INTRODUCTION TO JDBC - Revised spring 2004 - 1 What is JDBC? Java Database Connectivity (JDBC) is a package in the Java programming language and consists of several Java classes that deal with database

More information

Running SQL in Java and PHP

Running SQL in Java and PHP Running SQL in Java and PHP FCDB 9.6 9.7 Dr. Chris Mayfield Department of Computer Science James Madison University Feb 28, 2018 Introduction to JDBC JDBC = Java Database Connectivity 1. Connect to the

More information

Accessing databases in Java using JDBC

Accessing databases in Java using JDBC Accessing databases in Java using JDBC Introduction JDBC is an API for Java that allows working with relational databases. JDBC offers the possibility to use SQL statements for DDL and DML statements.

More information

SQL in a Server Environment

SQL in a Server Environment SQL in a Server Environment Vaidė Narváez Computer Information Systems January 13th, 2011 The Three-Tier Architecture Application logic components Copyright c 2009 Pearson Education, Inc. Publishing as

More information

This lecture. PHP tags

This lecture. PHP tags This lecture Databases I This covers the (absolute) basics of and how to connect to a database using MDB2. (GF Royle 2006-8, N Spadaccini 2008) I 1 / 24 (GF Royle 2006-8, N Spadaccini 2008) I 2 / 24 What

More information

Constraints. Local and Global Constraints Triggers

Constraints. Local and Global Constraints Triggers Constraints Foreign Keys Local and Global Constraints Triggers 1 Constraints and Triggers A constraint is a relationship among data elements that the DBMS is required to enforce. Example: key constraints.

More information

Part I: Stored Procedures. Introduction to SQL Programming Techniques. CSC 375, Fall 2017

Part I: Stored Procedures. Introduction to SQL Programming Techniques. CSC 375, Fall 2017 Introduction to SQL Programming Techniques CSC 375, Fall 2017 The Six Phases of a Project: Enthusiasm Disillusionment Panic Search for the Guilty Punishment of the Innocent Praise for non-participants

More information

Programming in Java

Programming in Java 320341 Programming in Java Fall Semester 2014 Lecture 16: Introduction to Database Programming Instructor: Slides: Jürgen Schönwälder Bendick Mahleko Objectives This lecture introduces the following -

More information

Databases PHP I. (GF Royle, N Spadaccini ) PHP I 1 / 24

Databases PHP I. (GF Royle, N Spadaccini ) PHP I 1 / 24 Databases PHP I (GF Royle, N Spadaccini 2006-2010) PHP I 1 / 24 This lecture This covers the (absolute) basics of PHP and how to connect to a database using MDB2. (GF Royle, N Spadaccini 2006-2010) PHP

More information

From E/R Diagrams to Relations

From E/R Diagrams to Relations From E/R Diagrams to Relations Entity set relation Attributes attributes Relationships relations whose attributes are only: The keys of the connected entity sets Attributes of the relationship itself 1

More information

Stored procedures - what is it?

Stored procedures - what is it? For a long time to suffer with this issue. Literature on the Internet a lot. I had to ask around at different forums, deeper digging in the manual and explain to himself some weird moments. So, short of

More information

COP4540 TUTORIAL PROFESSOR: DR SHU-CHING CHEN TA: H S IN-YU HA

COP4540 TUTORIAL PROFESSOR: DR SHU-CHING CHEN TA: H S IN-YU HA COP4540 TUTORIAL PROFESSOR: DR SHU-CHING CHEN TA: H S IN-YU HA OUTLINE Postgresql installation Introduction of JDBC Stored Procedure POSTGRES INSTALLATION (1) Extract the source file Start the configuration

More information

CS145 Introduction. About CS145 Relational Model, Schemas, SQL Semistructured Model, XML

CS145 Introduction. About CS145 Relational Model, Schemas, SQL Semistructured Model, XML CS145 Introduction About CS145 Relational Model, Schemas, SQL Semistructured Model, XML 1 Content of CS145 Design of databases. E/R model, relational model, semistructured model, XML, UML, ODL. Database

More information

CSCI3030U Database Models

CSCI3030U Database Models CSCI3030U Database Models CSCI3030U RELATIONAL MODEL SEMISTRUCTURED MODEL 1 Content Design of databases. relational model, semistructured model. Database programming. SQL, XPath, XQuery. Not DBMS implementation.

More information

First lecture of this chapter is in slides (PPT file)

First lecture of this chapter is in slides (PPT file) First lecture of this chapter is in slides (PPT file) Review of referential integrity CREATE TABLE other_table ( b1 INTEGER, c1 INTEGER, PRIMARY KEY (b1, c1) ) CREATE TABLE t ( a integer PRIMARY KEY, b2

More information

JDBC. Sun Microsystems has included JDBC API as a part of J2SDK to develop Java applications that can communicate with databases.

JDBC. Sun Microsystems has included JDBC API as a part of J2SDK to develop Java applications that can communicate with databases. JDBC The JDBC TM API is the application programming interface that provides universal data access for the Java TM platform. In other words, the JDBC API is used to work with a relational database or other

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Chapter 11 Outline A Simple PHP Example Overview of Basic Features of PHP Overview of PHP Database Programming Slide 11-2 Web Database Programming Using PHP Techniques for programming dynamic features

More information

CPSC 421 Database Management Systems. Lecture 10: Embedded SQL

CPSC 421 Database Management Systems. Lecture 10: Embedded SQL CPSC 421 Database Management Systems Lecture 10: Embedded SQL * Some material adapted from R. Ramakrishnan, L. Delcambre, and B. Ludaescher Today s Agenda Quiz Project Part 2 Embedded SQL DDL and DML Notes:

More information

SQL: Programming. Introduction to Databases CompSci 316 Fall 2017

SQL: Programming. Introduction to Databases CompSci 316 Fall 2017 SQL: Programming Introduction to Databases CompSci 316 Fall 2017 2 Announcements (Thu., Oct. 12) Project milestone #1 due tonight Only one member per team needs to submit Remember members.txt Midterm is

More information

INTRODUCTION TO JDBC - Revised Spring

INTRODUCTION TO JDBC - Revised Spring INTRODUCTION TO JDBC - Revised Spring 2006 - 1 What is JDBC? Java Database Connectivity (JDBC) is an Application Programmers Interface (API) that defines how a Java program can connect and exchange data

More information

Chapter 11 Outline. A Simple PHP Example Overview of Basic Features of PHP Overview of PHP Database Programming. Slide 11-2

Chapter 11 Outline. A Simple PHP Example Overview of Basic Features of PHP Overview of PHP Database Programming. Slide 11-2 Chapter 11 Outline A Simple PHP Example Overview of Basic Features of PHP Overview of PHP Database Programming Slide 11-2 1 Web Database Programming Using PHP Techniques for programming dynamic features

More information

Introduction to SQL. Select-From-Where Statements Multirelation Queries Subqueries

Introduction to SQL. Select-From-Where Statements Multirelation Queries Subqueries Introduction to SQL Select-From-Where Statements Multirelation Queries Subqueries 122 Why SQL? SQL is a very-high-level language. Say what to do rather than how to do it. Database management system figures

More information

ADVANTAGES. Via PL/SQL, all sorts of calculations can be done quickly and efficiently without use of Oracle engine.

ADVANTAGES. Via PL/SQL, all sorts of calculations can be done quickly and efficiently without use of Oracle engine. 1 PL/SQL INTRODUCTION SQL does not have procedural capabilities. SQL does not provide the programming techniques of condition checking, looping and branching that is required for data before permanent

More information

CHAPTER 44. Java Stored Procedures

CHAPTER 44. Java Stored Procedures CHAPTER 44 Java Stored Procedures 752 Oracle Database 12c: The Complete Reference You can write stored procedures, triggers, object type methods, and functions that call Java classes. In this chapter,

More information

JDBC Drivers Type. JDBC drivers implement the defined interfaces in the JDBC API for interacting with your database server.

JDBC Drivers Type. JDBC drivers implement the defined interfaces in the JDBC API for interacting with your database server. JDBC Drivers Type 1 What is JDBC Driver? JDBC drivers implement the defined interfaces in the JDBC API for interacting with your database server. For example, using JDBC drivers enable you to open database

More information

UNIT III - JDBC Two Marks

UNIT III - JDBC Two Marks UNIT III - JDBC Two Marks 1.What is JDBC? JDBC stands for Java Database Connectivity, which is a standard Java API for databaseindependent connectivity between the Java programming language and a wide

More information