CS122aSlides14

CS122aSlides14 - ICS122A / EECS116 Introduction to Data...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
ICS122A / EECS116 Introduction to Data Management Spring 2009 Prof. Mike Carey Bren School of ICS UC Irvine Slides based on previous CS122a lecture notes as well as  material borrowed from U-Wisconsin, Stanford, & Berkeley
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS122A/EECS116 Notes 14 2 Announcements Midterm grades Choice (a) in Question 2 is also correct – if you lost points by saying so, you can visit Vivek for a grade correction Homework and project related notes HW #5 is due tonight by midnight HW #6 will be available by that time as well Project Part 3 is due on Thursday by midnight (Please include your latest E-R and relational schemas) This week: Database programming concepts Today: Client programming and stored procedures Thursday: Transactions and transaction management (Reminder: This Thursday’s office hour will be 12:30-1:30PM) Any Q&A before we move ahead…?
Background image of page 2
Overview Writing SQL Applications Basic concepts Host languages Compilation of embedded SQL program s Several major approaches Direct embedding of SQL E.g. embedded SQL, SQLJ (examples in DB2) Using libraries provided by host languages E.g. CLI (Call-Level Interface), ODBC (Open Database Connectivity), Java Database Connectivity (JDBC) Object-relational mapping (e.g., Hibernate and JPA) Stored Procedures (a.k.a. Persistent Stored Modules (PSM)) Motivation and benefits Parameters and parameter passing Notes 14 3 CS122A/EECS116
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Embedded SQL Direct SQL is rarely used in practice (outside development) Instead, SQL is usually “embedded” in application code Q: Why not use only one language? Host language + embedded SQL  Preprocessor Host Language + function calls Host language compiler Host language  program Advantages Preprocessing of (static) parts of queries Disadvantages Needs pre-compiler Needs to be bound to a database SQL library Notes 14 4 CS122A/EECS116
Background image of page 4
The Impedance Mismatch Problem No construct in host languages for manipulating relations Host languages manipulate instances: variables, values, pointers SQL statements manipulate relations: sets, bags E.g. what if a query returns more than one tuple?! Interface between SQL and host languages: Host variables Values are passed between a SQL statement and the rest of the program Colon precedes a shared variable that occurs within a SQL statement SQL communications area EXEC SQL INCLUDE SQLCA Defines: status codes, error messages, etc. EXEC SQL precedes each SQL-related statement in a host program Notes 14 5 CS122A/EECS116
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Example Void  simpleInsert() {      EXEC SQL BEGIN DECLARE SECTION;               char productName[20], company[30];               char SQLSTATE[6];      EXEC SQL END DECLARE SECTION;   /* get values for productName and company somehow  */
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 23

CS122aSlides14 - ICS122A / EECS116 Introduction to Data...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online