12 : Pro*C/C++ 1 C/C++, Cobol, Fortran, Ada, Pascal 3GL SQL Pre-Compiler,, SQL PL/SQL C Pro*C Pro*C C++ Oracle 8 ProC/C++ Pro*C/C++ 11 Pro*C, Pro C, C/C++ Pro C / cc gcc, C++ Pro*C SQL ANSI SQL 8, ANSI SQL DBMS 111 Pro *C Pro *C C Pro *C 1 : Pro *C 2 Pro *C : Pro *CSQL C/C++ Pro *C 3 C : C/C++ C Pro*C 1
(library) Pro*C OCI(Oracle Call Interface) Pro*C, Pro*C SQL, C 112 Relink makefile, $ORACLE_HOME/precomp/lib/ins_precompmk Relink make $ make -f ins_precompmk relink EXENAME=executable $ORACLE_HOME/precomp/lib $ORACLE_HOME/bin $ORACLE_HOME/bin, : $ make -f ins_precompmk executable Pro*C/C++ Object Type Translator Proc Ott, Pro*C/C++ relink, : $ cd $ORACLE_HOME/precomp/lib $ make -f ins_precompmk relink EXENAME=proc 113 $ORACLE_HOME/precomp/admin cfg Pro*C/C++ v805 Object Type Translator v805 pcscfgcfg ottcfgcfg 114 C, (subprogram) "No such user exit" iapxtb 2
(debugger) ireclen and oreclen The ireclen oreclen 12 Pro*C/C++ Pro*C/C++ release 805, $ORACLE_HOME/precomp/doc/proc2/readmedoc README 121 Pro*C/C++ $ORACLE_HOME/precomp/admin/pcscfgcfg 122 Pro*C/C++ Pro*C/C++, Oracle8 Installation Guide for LINUX Chapter1 123 Demo (Demonstration Programs) Pro*C/C++ Demo 3 Demo : C, C++ Object Program - Oracle8 Demo $ORACLE_HOME/precomp/demo/proc, TIGER SCOTT $ORACLE_HOME/sqlplus/demo/demobldsql Demo $ORACLE_HOME/precomp/demo/proc/demo_procmk makefile Demo, sample1 Demo, link $ make -f demo_procmk sample1, $ make -f demo_procmk build OBJS=sample1o EXE=sample1 $ORACLE_HOME/lib/libclntshso link Pro*C/C++ C Demo, : $ make -f demo_procmk samples Pro*C/C++ C++ Demo, : $ make -f demo_procmk cppsamples Pro*C/C++ Object Demo, : 3
$ make -f demo_procmk object_samples Demo $ORACLE_HOME/precomp/demo/sql SQL Demo, SQL script make RUNSQL=run, calldemo Demo $ORACLE_HOME/precomp/demo/sql/calldemosql : $ make -f demo_procmk calldemo RUNSQL=run, Object Demo SQL $ make -f demo_procmk object_samples RUNSQL=run SQL 124 (User Programs) $ORACLE_HOME/precomp/demo/proc/demo_procmk makefile demo_procmk link : $ make -f demo_procmk target OBJS="objfile1 objfile2 " \ EXE=exename, Pro*C/C++ myprogpc myprog C link : $ make -f demo_procmk build OBJS=myprogo EXE=myprog C link : $ make -f demo_procmk build_static OBJS=myprogo EXE=myprog C++ client shared library link : $ make -f demo_procmk cppbuild OBJS=myprogo EXE=myprog C++ link : $ make -f demo_procmk cppbuild_static OBJS=myprogo EXE=myprog LINUX 13 131 Oracle Call Interface Oracle Call Interface (OCI), 4
Oracle8 Installation Guide for LINUX Chapter 1 132 Demo OCI Demo Demo C, C++ 2 Demo $ORACLE_HOME/rdbms/demo Demo TIGER SCOTT $ORACLE_HOME/sqlplus/demo/demobldsql Demo $ORACLE_HOME/rdbms/demo/demo_rdbmsmk makefile, cdemo1, link : $ make -f demo_rdbmsmk cdemo1, : $ make -f demo_rdbmsmk build OBJS=cdemo1o EXE=cdemo1 $ORACLE_HOME/lib/libclntshso client shared library link OCI C Demo : $ make -f demo_rdbmsmk demos OCI C++ Demo : $ make -f demo_rdbmsmk c++demos Note: C++ link : ld: fatal: library -lsunmath: not found ld: fatal: library -lc: not found ld: fatal: library -lc_mtstubs: not found ld: fatal: library -lcx: not found LD_LIBRARY_PATH Demo $ORALCE_HOME/rdbms/demo SQL, SQL sql, oci02 SQL oci02sql SQL 133 (User Programs) $ORACLE_HOME/rdbms/demo/demo_rdbmsmk demo_rdbmsmk link : $ make -f demo_rdbmsmk target OBJS="objfile1 objfile2 " \ EXE=exename makefile 5
, myprogc C myprog : C client shared library link : $ make -f demo_rdbmsmk build OBJS=myprogo EXE=myprog C link : $ make -f demo_rdbmsmk build_static OBJS=myprogo EXE=myprog myproccc C++ myprog : C++ client shared library link : $ make -f demo_rdbmsmk buildc++ OBJS=myprogo EXE=myprog C++ link : $ make -f demo_rdbmsmk buildc++_static OBJS=myprogo EXE=myprog 14 Oracle Link Makefile 141 Makefiles(Custom Makefiles) demo_productmk makefiles link makefile makefile : symbol link, sms link line : 1 A B, B A 2 Solaris linker one-pass linker linker link line point link line, link line ddemo_productmk makefile 142 Undefined Symbols link symbol : $ make -f demo_procmk sample1 Undefined first referenced symbol in file sqlcex sample1o 6
sqlglm sample1o ld: fatal: Symbol referencing errors No output written to sample1 linker symbol link line object linker object symfind sqlcex symbol symfind : $ symfind sqlcex SymFind - Find Symbol <sqlcex> in <**>a, o, so ------------------------------------------------------ Command: /u01/app/oracle/product/805/bin/symfind sqlcex Local Directory: /u01/app/oracle/product/805 Output File: Note: (none) I do not traverse symbolic links Use '-v' option to show any symbolic links Locating Archive and Object files [11645] 467572 44 FUNC GLOB 0 8 sqlcex ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /lib/libclntshso [35] 0 44 FUNC GLOB 0 5 sqlcex ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /lib/libsqla 143 Thread Support, (multi-threaded applications) 15 Static Dynamic Linking OCI, link link, object link, link, (run-time) link link link : 1 : 2 : (ie, the in-memory copy) 7
151 (Oracle shared library) $ORACLE_HOME/lib/libclntshso link demo_productmk makefile, (runtime loader) LD_LIBRARY_PATH, LD_LIBRARY_PATH % sample1 ldso1: sample1: fatal: libclntshso10: can't open file: errno=2 Killed LD_LIBRARY_PATH : % setenv LD_LIBRARY_PATH $ORACLE_HOME/lib, SQL*Plus Recovery Manager, oracle % cd $ORACLE_HOME/rdbms/lib % make -f ins_rdbmsmk client_sharedlib 16 Signal Handlers 8 (two-task communication) signal handler 161 Signals Signal 8 (two-task communication) signal : SIGCONT SIGINT SIGPIPE oracle signal(out-of-band breaks) pipe tow-task driver two-task driver SIGINT oracle ; (end-of-file) pipe driver pipe,, SIGPIPE signal (Writing) SIGPIPE oracle 8
SIGCLD SIGTERM SIGIO SIGURG pipe driver SIGCLD SIGPIPE, oracle oracle, LINUX SIGCLD ( wait() signal handler ) SIGCLD oracle, oracle pipe driver [Ctrl]+[c] SIGTERM ; oracle Oracle Net8 protocol adapters oracle signal(out-of-band breaks) Oracle Net8 TCP/IP driver signal signal Pro*C SIGCLD ( SIGCHLD) SIGPIPE signal handler osnsui() SIGINT multiple signal handler signal signal the oracle process, multiple signal handler 162 Signal signal catching SIGINT signalcatching osnsui() osncui() /* */ word osnsui( /*_ word *handlp, void (*astp), char * ctx, _*/) /* ** osnsui: ** handling procedure astp ** (^C ) ctx astp ** handler *handlp osncui ** handler ** osncui ** */ /* */ word osncui( /*_ word handle _*/ ); /* ** osncui : ** handler osnsui handle ** aksdir */ osnsui() osncui() : 9
/* ** handler */ void sig_handler() { main(argc, argv) int arc; char **argv; { int handle, err; /* */ if (err = osnsui(&handle, sig_handler, (char *) 0)) { /* 0, */ /* */ if (err = osncui(handle)) { /* 0, */ 17 XA Functionality XA TP- link line TP- (ax_reg ax_unreg symbol ) link XA (Oracle XA switch xaoswd) Oracle8 Oracle7 716 XA ( 73 XA ) 716 XA TP- XA Oracle8 XA link Oracle8 XA $ORACLE_HOME/lib/libclntshso $ORACLE_HOME/lib/libclienta 10
2 Embeded SQL Pro*C C/C++ Embedded SQL, SQL INSERT, DELETE, UPDATE SQL C 21 Pro*C SQL Pro*C SQL SQL SQL SQL*Plus Pro*C SQL DDL(Data Definition Language) : ALTER, ANALYZE, AUDIT, COMMENT, CREATE, DROP, GRANT, NOAUDIT, RENAME, REVOKE, TRUNCATE DML(Data Manipulation Language) : DELETE, INSERT, SELECT, UPDATE, EXPLAIN PLAN, LOCK TABLE : ALTER SESSION, SET ROLE : ALTER SYSTEM : COMMIT, ROLLBACK, SAVEPOINT, SET TRANSACTION SQL Pro*C EXEC SQL, (:) / *EXEC SQL */ EXEC SQL COMMIT WORK RELEASE; EXEC SQL Pro*C SQLLIB C 22 Embeded SQL Embeded SQL,, SQL,, Pro*C, emp emp empno,ename,sal deptno #include<stdioh> /* */ 11
EXEC SQL BEGIN DECLARE SECTION; VARCHAR user_id[20]; VARCHAR passwd[20]; int emp_number; VARCHAR emp_name[20]; int emp_dept; float emp_salary; EXEC SQL END DECLARE SECTION; /* */ EXEC SQL INCLUDE SQLCA; /* */ main() { printf("\n Enter User ID :"); scanf("%s", iser_idarr); printf("\n Enter Passward :"); scanf("%s", passwdarr); iuser_idlen = strln(user_isarr); passwdlen = strln(passwdarr); /* */ EXEC SQL CONNECT :user_id IDENTIFIED BY :passwd; if (sqlcasqlcode < 0) { printf("\n@s", sqlcasqlerrmsqlerrmc); EXEC SQL ROLLBACK WORK RELEASE; exit(1); else { printf("\nconnected to Oracle"); EXEC SQL COMMIT WORK RELEASE; getdata(); exit(0); void getdata() { 12
printf("\n Enter Employee Number to Query:"); scanf("%d\n", emp_number); /* */ EXEC SQL SELECT ename INTO :emp_name FROM emp WHERE emp_no =: emp_number; EXEC SQL SELECT deptno INTO :emp_dept FROM emp WHERE dept_no =: emp_number; EXEC SQL SELECT sql INTO :emp_salary FROM emp WHERE sal =: emp_number; printf("\n Emplyoee %d :", emp_number); printf("\n Name : %s", emp_namearr); printf("\n Salary : %f", emp_salary); printf("\n Dept : %d", emp_dept); C C SQL SQL C/C++ SQL EXEC SQL, SQL SQL PL/SQL 221 SQL, BEGIN DECLARE SECTION END DECLARE SECTION, VARCHAR Pro*C struct { short len; char arr[len]; Pro*C VARCHAR VARCHAR // EXEC SQL BEGIN DECLARE SECTION; VARCHAR user_id[20]; VARCHAR passwd[20]; int emp_number; VRCHAR emp_name[20]; int emp_dept; real emp_salary; 13
EXEC SQL END DECLARE SECTION; 222 SQLCA // EXEC SQL INCLUDE SQLCA; 223 CONNECT Pro*C SQL, CONNECT :' VACHAR arr len scanf arr len // printf("\n Enter User ID :"); scanf("%s", iser_idarr); printf("\n Enter Passward :"); scanf("%s", passwdarr); iuser_idlen = strln(user_isarr); passwdlen = strln(passwdarr); EXEC SQL CONNECT :user_id IDENTIFIED BY :passwd; 224 Pro*C EXEC SQL 0, sqlerrm sqlcasqlerrmsqlerrmc, ROOBACK WORK RELEASE, COMMIT WORK RELEASE (commit), // if (sqlcasqlcode < 0) { printf("\n@s", sqlcasqlerrmsqlerrmc); EXEC SQL ROLLBACK WORK RELEASE; exit(1); 14
else { printf("\nconnected to Oracle"); EXEC SQL COMMIT WORK RELEASE; getdata(); exit(); 225 SQL,, SELECT, EXEC SQL (:) // void getdata() { printf("\n Enter Employee Number to Query:"); scanf("%d\n", emp_number); /* */ EXEC SQL SELECT ename INTO :emp_name FROM emp WHERE emp_no =: emp_number; EXEC SQL SELECT deptno INTO :emp_dept FROM emp WHERE dept_no =: emp_number; EXEC SQL SELECT sql INTO :emp_salary FROM emp WHERE sal =: emp_number; printf("\n Emplyoee %d :", emp_number); printf("\n Name : %s", emp_name); printf("\n Salary : %s", emp_salary); printf("\n Dept : %s", emp_dept); 23 Pro*C Pro*C, Pro*C Pro*C empdatapc $ proc empdata Pro*C pc Pro*C pc, 15
Pro*C INAME, $ proc INAME = empdata Pro*C,, Pro*C Pro*C, Pro*C Pro*C? C /? $ proc? Pro*C pmscfgh proc 231 Pro*C, (1) INAME :, ` INAME = filename filename Pro*C INAME pc (2) CPP_SUFFIX : CODE CPP Pro*C, code = CPP CPP_SUFFIX = gcc gcc CPP_SUFFIX (3) ONAME : Pro*C ONAME = output_filename output_filename, c CPP_SUFFIX, ONAME ONAME proc sample oname = sample001c ONAME c proc sample samplec 16
(4) CONFIG :, CONFIG, filename CONFIG = filename (5) INCLUDE : Include, INCLUDE = pathname, INCLUDE =(pathname, path_name,) Include () Include, Pro *C Include 1 SYS_INCLUDED 2 3 4 INCLUDE, sqlcah Pro *C Include Pro *C, Include (6) SYS_INCLUDE :, SYS_INCLUDE = path_name path_name (7) LNAME : Pro *C,,, LNAME = listing_filename listing_filenaem, lis (8) LTYPE :, LTYPE = NONE, SHORT, LONG, LONG, SHORT NONE (9) COM_CHARSET :,, MULTI_BYTE, MULTI_BYTE SINGLE_BYTE MULTI_BYTE COMP_CHARSET = MULTI_BYTE COMP_CHARSET MULTI_BYTE Pro*C MULTI_BYTE MULTI_BYTE (10) CODE :,, ANSI_C,KR_C CPP KR_C CODE = ANSI_C C ANSI_C ANSI_C 17
KR_C CPP C++ (11) DBMS : SQL, DBMS = NATIVE V6, V7, PRO *C SQL 6 NATIVE (12) ERRORS :, YES,NO YES ERRORS = YES, NO (13) FIPS : ANSI SQL SQL, FIPS = YES, SQL89, NO, NONE NONE FIPS YES, SQL, Pro *c Pro *c SQL 1 SQLCA, ORACA, SQLDA, 2 Embedded PL/SQL 3 DATE,NUMBER, RA, LONGRAW, VARCHAR2 4 CONNECT (14) MAXOPENCURSORS : Pro *C OPENCURSOR, 10 MAXOPENCURSORS = (15) ORACA : ORACA = YES, NO NO, YES EXEC SQL INCLUDE ORACA #INCLUDE oracah (16) PARSE : PRO *C, PARSE = FULL, PARTIAL, NONE PARSE FULL, FULL C C++ NONE, PARATIAL (17) SELECT_ERROW : SELECT,, YES SELECT_ERROW = YES, NO 3 18