ICS 321 Fall 2009 DBMS Application Programming Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 10/06/20091Lipyeow.

Slides:



Advertisements
Similar presentations
Owners Roles DB Objects Grant Revoke Grant Revoke Grant Revoke (*) with admin option Il ruolo …. È un set di system & object privileges Non appartiene.
Advertisements

SQL*PLUS, PLSQL and SQLLDR Ali Obaidi. SQL Advantages High level – Builds on relational algebra and calculus – Powerful operations – Enables automatic.
Stored Procedure Language Stored Procedure Overview Stored Procedure is a function in a shared library accessible to the database server can also write.
CSC343 – Introduction to databases – A. Vaisman1 Database Application Development.
Objective: To access a database from an application program (as opposed to interactive interfaces) Why? An interactive interface is convenient but not.
ICS 421 Spring 2010 Distributed Transactions Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 3/16/20101Lipyeow.
ICS 421 Spring 2010 Data Warehousing (1) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 3/18/20101Lipyeow.
Embedded SQL John Ortiz. Lecture 15Embedded SQL2 Why Isn’t Interactive SQL Enough?  How to do this using interactive SQL?  Print a well-formatted transcript.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 Introduction to SQL Programming Techniques.
--What is a Database--1 What is a database What is a Database.
Murali Mani SQL with other Programming Languages.
METU Department of Computer Eng Ceng 302 Introduction to DBMS SQL: Assertions, Views, and Programming Techniques by Pinar Senkul resources: mostly froom.
SPRING 2004CENG 3521 SQL: Constraints, Triggers, Embedded SQL Chapters: 5, 6.
1 C. Shahabi Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California
EmbeddedSQL: 1 Impedance Mismatch Problem Problem : How to connect SQL statements with conventional programming languages Different models of language.
Computer Science & Engineering 2111 CSE 2111 Lecture Querying a Database 1CSE 2111 Lecture- Querying a Database.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
ODBC Open DataBase Connectivity a standard database access method developed by Microsoft to access data from any application regardless of which database.
Database Applications.  Database Programming  Web databases  Application architecture.
1 Section 6 Embedded SQL. 6-2 CA306 Embedded SQL Section Content 6.1Embedded SQL 6.2Java Database Connectivity 6.3Web Databases.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
Overview of JDBC and Pro*C 1 Overview of JDBC,Pro*C and Oracle connectivity on Omega CSE 5330 – Database Systems.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke; edited K. Shomper1 Database Application Development Chapter 6.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Database Application Development Chapter 6.
Announcements Read JDBC Project Step 5, due Monday.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 9- 1 DATADABASE PROGRAMMING 2Chapter 13 from our text.
1 No class Thurs. Oct. 2 E-day Exam 1 Thurs. Oct. 9 HW3 Oct. 2 to –Available Oct 2 only until 2 pm.
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)
CS 405G: Introduction to Database Systems Database programming.
Overview of JDBC and Pro*C 1 CSE 5330 – Database Systems.
ICS 321 Fall 2009 ODBC, JDBC & Stored Procedures Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 10/8/20091Lipyeow.
Dr Gordon Russell, Napier University Unit Embedded SQL - V3.0 1 Embedded SQL Unit 5.1.
Mainframe (Host) - Communications - User Interface - Business Logic - DBMS - Operating System - Storage (DB Files) Terminal (Display/Keyboard) Terminal.
An Introduction to SQL Prof. Yin-Fu Huang CSIE, NYUST Chapter 4.
Stored Procedures Week 9. Test Details Stored Procedures SQL can call code written in iSeries High Level Languages –Called stored procedures SQL has.
ICS 321 Fall 2010 SQL in a Server Environment (i) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 11/1/20101Lipyeow.
Programmatic SQL Shaista Khan CS 157B. Topic Embedded SQL statements in high-level programming languages.
SQL in a Programming Environment CIS 4301 Lecture Notes Lecture /11/2006.
CSC 312 Lecture 10 JDBC - Basics. Network Client Machine Server Machine (raptor.cs.mercer.edu) Client Application Server Prog. (Oracle) Database (csc312std)
1 CS 430 Database Theory Winter 2005 Lecture 14: Additional SQL Topics.
Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Communicating with the Outside. Hardware [Processor(s), Disk(s), Memory] Operating System Concurrency ControlRecovery Storage Subsystem Indexes Query.
Dr Gordon Russell, Napier University Unit Embedde SQL - V2.0 1 Embedded SQL Unit 5.1.
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.
WEB SERVER SOFTWARE FEATURE SETS
Development Overview Pertemuan 11 Matakuliah: T0413 Tahun: 2009.
Object storage and object interoperability
Database Management Systems 1 Raghu Ramakrishnan Database Application Development Chpt 6 Xin Zhang.
© 1997 UW CSE 10/27/97H-1 Embedded SQL and the CLI Chapter 7.7.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
RETRIEVE A NO. OF ROWS ¦ Declare a cursor ¦ Open the cursor ¦ Fetch rows of data ¦ Stop fetching rows ¦ Close the cursor.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Database Application Development Chapter 6.
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.
ISC321 Database Systems I Chapter 2: Overview of Database Languages and Architectures Fall 2015 Dr. Abdullah Almutairi.
10/3/2017.
Chapter 4 An Introduction to SQL.
1st Semester, 2017 Sanghyun Park
Introduction to SQL Programming Techniques
SQL Environment.
Introduction to Database Systems, CS420
Chapter 5: Advanced SQL Database System concepts,6th Ed.
CS122B: Projects in Databases and Web Applications Spring 2017
CS122B: Projects in Databases and Web Applications Winter 2017
Database Application Development
DB Programming: SQL Programming Techniques
Introduction to SQL Programming Techniques
Dynamic SQL The dynamic SQL component of SQL allows programs to construct and submit SQL queries at run time. In contrast, embedded SQL statements must.
Stored Procedure Language
Presentation transcript:

ICS 321 Fall 2009 DBMS Application Programming Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 10/06/20091Lipyeow Lim -- University of Hawaii at Manoa

SQL & Other Programming Languages Two extremes of the integration spectrum: Highly integrated eg. Microsoft linq – Compiler checking of database operations Loosely integrated eg. ODBC & JDBC – Provides a way to call SQL from host language – Host language compiler doesn’t understand database operations. Requirements: – Perform DB operations from host language – DB operations need to access variables in host language 10/06/2009Lipyeow Lim -- University of Hawaii at Manoa2

Remote Client Access Applications run on a machine that is separate from the DB server DBMS “thin” client – Libraries to link your app to – App needs to know how to talk to DBMS server via network DBMS “full” client layer – Need to pre-configure the thick client layer to talk to DBMS server – Your app talks to a DBMS client layer as if it is talking to the server 10/06/2009Lipyeow Lim -- University of Hawaii at Manoa3 Server DBMS App DB Libs App DB Client What information is needed for 2 machines to talk over a network ?

Configuring DBMS Client Layer Tell the client where to find the server db2 CATALOG TCPIP NODE mydbsrv REMOTE SERVER Tell the client where to find the server db2 CATALOG DATABASE bookdb AS mybookdb AT NODE mydbsrv 10/06/2009Lipyeow Lim -- University of Hawaii at Manoa4 Give a name for this node Specify the IP address/hostnam e and the port number of the DB server machine Specify the name of the database on the server Give a local alias for the database Specify the name of the node that is associated with this database

Embedded SQL in C Programs DBMS-specific Preprocessor translates special macros to DB- specific function calls Pre-processor needs access to DBMS instance for validation. Executable needs to be bound to a specific database in a DBMS in order to execute 10/06/2009Lipyeow Lim -- University of Hawaii at Manoa5.sqc DBMS-specific Precompiler.c C Compiler C Linker DBMS-specific Binder.bnd.o DBMS- specific libraries.exe Database package

An Example of Embedded SQL C Program #include int main() { // Include The SQLCA Data Structure Variable EXEC SQL INCLUDE SQLCA; // Define The SQL Host Variables Needed EXEC SQL BEGIN DECLARE SECTION; char EmployeeNo[7]; char LastName[16]; double Salary; short SalaryNI; EXEC SQL END DECLARE SECTION; // Connect To The Appropriate Database EXEC SQL CONNECT TO SAMPLE USER db2admin USING ibmdb2; // Declare A Static Cursor EXEC SQL DECLARE C1 CURSOR FOR SELECT EMPNO, LASTNAME, DOUBLE(SALARY) FROM EMPLOYEE WHERE JOB = 'DESIGNER'; // Open The Cursor EXEC SQL OPEN C1; 10/06/2009Lipyeow Lim -- University of Hawaii at Manoa6

An Example of Embedded SQL C Program // If The Cursor Was Opened Successfully, while (sqlca.sqlcode == SQL_RC_OK) { EXEC SQL FETCH C1 INTO :EmployeeNo, :LastName, :Salary, :SalaryNI; // Display The Record Retrieved if (sqlca.sqlcode == SQL_RC_OK) { printf("%-8s %-16s ", EmployeeNo, LastName); if (SalaryNI >= 0) printf("%lf\n", Salary); else printf("Unknown\n"); } // Close The Open Cursor EXEC SQL CLOSE C1; // Commit The Transaction EXEC SQL COMMIT; // Terminate The Database Connection EXEC SQL DISCONNECT CURRENT; // Return Control To The Operating System return(0); } A cursor is an iterator for looping through a relation instance. Why is a cursor construct necessary ? 10/06/2009Lipyeow Lim -- University of Hawaii at Manoa7

Static vs Dynamic SQL Static SQL refers to SQL queries that are completely specified at compile time. Eg. // Declare A Static Cursor EXEC SQL DECLARE C1 CURSOR FOR SELECT EMPNO, LASTNAME, DOUBLE(SALARY) FROM EMPLOYEE WHERE JOB = 'DESIGNER'; Dynamic SQL refers to SQL queries that are note completely specified at compile time. Eg. strcpy(SQLStmt, “SELECT * FROM EMPLOYEE WHERE JOB="); strcat(SQLStmt, argv[1]); EXEC SQL PREPARE SQL_STMT FROM :SQLStmt; EXEC SQL EXECUTE SQL_STMT; 10/06/2009Lipyeow Lim -- University of Hawaii at Manoa8