Download presentation
Presentation is loading. Please wait.
1
M.P. Johnson, DBMS, Stern/NYU, Sp20041 C20.0046: Database Management Systems Lecture #17 Matthew P. Johnson Stern School of Business, NYU Spring, 2004
2
M.P. Johnson, DBMS, Stern/NYU, Sp2004 2 Agenda Previously: Pro*C, Midterm, break Next: Discuss midterm Project part 3 is up More programming for SQL Embedded SQL Pro*C, SQLJ PSMs CLI SQL/CLI in C JDBC in Java DBI/DBDs in Perl PHP (HTML?)
3
M.P. Johnson, DBMS, Stern/NYU, Sp2004 3 First: Evals Speed Varying depth of coverage Grades One-minute responses
4
M.P. Johnson, DBMS, Stern/NYU, Sp2004 4 Recap: Embedded SQL Host language + Embedded SQL Preprocessor Host Language + function calls Host language compiler Executable Preprocessor Host language compiler Oracle’s Pro*C gcc prog.pc prog.c a.out
5
M.P. Johnson, DBMS, Stern/NYU, Sp2004 5 Embedded SQL/Pro*C Benefits? Problems? Solutions?
6
M.P. Johnson, DBMS, Stern/NYU, Sp2004 6 Interface: SQL/Host Language Two languages: SQL, host (C/Java/whatever) Benefits: DB code (SQL is portable) SQL, host language focus on own strengths SQL code placed in host language code SQL and host language have diff. data types “impedance mismatch” Data transferred with “shared variables” Use cursors to access/modify data Error messages placed in SQLSTATE
7
M.P. Johnson, DBMS, Stern/NYU, Sp2004 7 Recall: Pro*C on sales Example script: sample1.pc See Pro*C tutorialPro*C tutorial Pro*C compiler is proc Must include /oracle/precomp/public Must link with shared library /oracle/lib/libclntsh.so Includes makefile proc.mk, but may require modifications sales% cp /oracle/precomp/demo/proc/*.pc. sales% proc sample1.pc sales% gcc -I/oracle/precomp/public /oracle/lib/libclntsh.so -osample1 sample1.c sales% sample1 sales% cp /oracle/precomp/demo/proc/*.pc. sales% proc sample1.pc sales% gcc -I/oracle/precomp/public /oracle/lib/libclntsh.so -osample1 sample1.c sales% sample1
8
M.P. Johnson, DBMS, Stern/NYU, Sp2004 8 Embedded SQL example Example script: sample2.pc See Pro*C tutorialPro*C tutorial Goal: display all salespeople Use cursor to scroll through results sales% proc sample2.pc sales% gcc -I/oracle/precomp/public /oracle/lib/libclntsh.so –osample2 sample2.c sales% sample2 sales% proc sample2.pc sales% gcc -I/oracle/precomp/public /oracle/lib/libclntsh.so –osample2 sample2.c sales% sample2
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.