• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            拂曉·明月·彎刀

            觀望,等待只能讓出現(xiàn)的機(jī)會(huì)白白溜走

              C++博客 :: 首頁(yè) ::  :: 聯(lián)系 :: 聚合  :: 管理 ::

            Oracle Database Development (6). A first exploration of OCI

            Vert Melon

            Jun 25,2007

            1.Preface

             Last time , i provided a full example of OCI , which contains the actual code of connection 
            and SQL . Certainly it could not cover all of the knowledge , but i think it is a good beginning 
            for the fresher .

             As the same as Pro*C you might confirm that you have installed it correctly .  Look at this 
            paths as follows :
             
             Windows   :   $ORACLE_HOME\oci
             Linux/Unix  :   $ORACLE_HOME/rdbms/demo
             
             There are many examples offered by ORACLE . Though it seems like a clutter , you also 
            can get some useful imformation .

             The main platform we use here is Linux .  And the Windows ?  How can i config it in Windows ? 
            It would be a comfy thing if you have read the chapters recorded in  <Oracle Database Development (1). Config OCI In Windows> .
            It is easily comprehend by analogy .


            2.Something you should know

             What is the Oracle Call Interface?

             The Oracle Call Interface (OCI) is a set of low-level APIs (Application Programming Interface Calls) 
            used to interact with Oracle databases. It allows one to use operations like logon, execute, 
            parse, fetch, etc. OCI programs are normally written in C or C++, although they can be written
            in almost any programing language. Unlike with the Oracle Precompilers (like Pro*C and Pro*COBOL), 
            OCI programs are not precompiled.

             Also I have found a official explaination about the choice between Pro*C and OCI .
             
             Should one use OCI or the Oracle Precompilers?
             
             OCI is superior to Pro*C in the following ways: 
              Performance is much better with OCI 
              Reduced code size 
              Direct access to built-in functions (No intermediate files or substitutions). 
              Piecewise Operation on LONG fields (All LONG field problems are solved) 
              In Pro*C one cannot dynamically allocate memory to be used as bind variables 
              You cannot control the Pro*C precompiler to provide better and more compilable C-code. 
              ...
               
             Common problems with OCI: 
              OCI code is difficult to write and to maintain 
              Very few people can write, let alone maintain OCI code 
              ...
              
             An OCI application program must do the following: 
              Connect to one or more databases: call the OCILogon (olog, olon or orlon) routines 
              Open the cursors needed by the program: use oexec, oexn, ofen or oftech calls. 
              Process the SQL statements that are needed to perform the application's tasks. 
              Close the cursors using the oclose routine. 
              Disconnect from the databases: use ologoff to close an open connection to oracle.  

            3.Obsolescent OCI Routines

             After get through the section "Something you should know" ,  you may find some strange 
            words : oexec , ologoff  or oclose . There are old routines in preceding release . 
             Release 8.0 of the Oracle Call Interface introduced an entirely new set of functions which 
            were not available in release 7.3. Release 8.1 added more new functions. Oracle9i OCI continues 
            to support these new functions, and adds more new calls. The earlier 7.x calls are still available, 
            but Oracle strongly recommends that existing applications use the new calls to improve performance 
            and provide increased functionality.
             To get more information ,  check it in the chapter named "Introduction and Upgrading" in 
            OCI document .


            4. Introduce to OCI Makefile

             It's time to make out the source file , and the first one is Makefile which is a trunk in a project .
            But then it is the end of  a first exploration .

             Notice that the head files of OCI are put in two directories and the lib file is libclntsh.so.9.0 
            which is the same as Pro*C .  This is a simple one ,  just copy the code in last article and 
            divide into the corresponding files as the list . Then use "make all" or "make clean" to deal with 
            the source file automaticly . You would see something like this .

            [root@liwei oci]# make clean;
            rm -f OCIDB OCIDB.o OCIException.o Exception.o OCIError.o Main.o
            [root@liwei oci]# make all;
            [OCIDB.o]
            ---------------------
            g++ -g -o OCIDB.o -I/home/ora/ora9/oracle/rdbms/demo -I/home/ora/ora9/oracle/rdbms/public -c OCIDB.cpp

            [OCIException.o]
            ---------------------
            g++ -g -o OCIException.o -I/home/ora/ora9/oracle/rdbms/demo -I/home/ora/ora9/oracle/rdbms/public -c OCIException.cpp

            [Exception.o]
            ---------------------
            g++ -g -o Exception.o -I/home/ora/ora9/oracle/rdbms/demo -I/home/ora/ora9/oracle/rdbms/public -c Exception.cpp

            [OCIError.o]
            ---------------------
            g++ -g -o OCIError.o -I/home/ora/ora9/oracle/rdbms/demo -I/home/ora/ora9/oracle/rdbms/public -c OCIError.cpp

            [Main.o]
            ---------------------
            g++ -g -o Main.o -I/home/ora/ora9/oracle/rdbms/demo -I/home/ora/ora9/oracle/rdbms/public -c Main.cpp

            [link] ... 
            ---------------------
            g++ -g -o OCIDB OCIDB.o OCIException.o Exception.o OCIError.o Main.o -L/home/ora/ora9/oracle/lib -lclntsh

             That's good . Take a rest for next step .

            -------------------------------------------------------------------------------------------------------

            Oracle數(shù)據(jù)庫(kù)開(kāi)發(fā)(六).OCI應(yīng)用初探

            草木瓜

            2007.6.25  
             
            一、序

             在上一次,我提供了一個(gè)完整的OCI示例,內(nèi)容包括數(shù)據(jù)庫(kù)連接和SQL操作的實(shí)際代碼。
            當(dāng)然一個(gè)小例子不可能包括所有內(nèi)容,不過(guò)我認(rèn)為對(duì)初學(xué)者是一個(gè)不錯(cuò)的開(kāi)始。

             與Pro*C一樣,需要確認(rèn)安裝OCI組件,查看下面的路徑:
             
             Windows   :   $ORACLE_HOME\oci
             Linux/Unix  :   $ORACLE_HOME/rdbms/demo
             
             這些目錄包含一些由ORACLE提供的一些示例。雖然有些雜亂,不過(guò)還是一些幫助的。
             我們這里使用的主要平臺(tái)是Linux。 Windows下怎么設(shè)置呢?可以參見(jiàn)《Oracle數(shù)據(jù)庫(kù)
            開(kāi)發(fā)(一).Windows下配置使用ProC》一文,都是類似的。


            二、一些你需要知道的東西

             OCI是什么 ?
             
             OCI是一組底層的API(應(yīng)用程序接口),主要和Oracle數(shù)據(jù)庫(kù)進(jìn)行交互。你可以調(diào)用一些
            操作如 logon , execute, parse, fecth 等等。OCI支持大數(shù)據(jù)語(yǔ)言,通常使用C/C++。與Oracle
            Pro*C等不同,OCI不需要預(yù)編譯。

             我這里也找著一份關(guān)于在Pro*C和OCI之間選擇的官方說(shuō)明。
             
             我應(yīng)該使用OCI還是Pro*C?
             
             OCI比Pro*C的一些優(yōu)勢(shì):
              
              OCI的性能十分出色
              代碼大量縮減
              對(duì)內(nèi)置函數(shù)直接訪問(wèn)
              對(duì)LONG類型的分段操作(可以處理LONG相關(guān)的任何錯(cuò)誤)
              Pro*C不能為綁定變量動(dòng)態(tài)分配內(nèi)存
              不能控制Pro*C自動(dòng)生成的代碼 
              
             OCI開(kāi)發(fā)的一些常見(jiàn)問(wèn)題:
             
              OCI代碼不容易掌握
              ...
              
             OCI開(kāi)發(fā)流程:
             
              連接多個(gè)數(shù)據(jù)庫(kù):使用OCILogon (olog, olon or orlon)
              打開(kāi)游標(biāo):oexec, oexn, ofen 或者 oftech
              執(zhí)行相應(yīng)SQL語(yǔ)句
              關(guān)于游標(biāo):oclose
              斷開(kāi)連接:ologoff
              
            三、廢棄的一些程序標(biāo)準(zhǔn)

             看過(guò)上節(jié),你會(huì)發(fā)現(xiàn)一些奇怪的單詞,oexec , ologoff  或 oclose 。這些都是先前版本
            舊的OCI標(biāo)準(zhǔn)。

             OCI 8.0 引入一套全新的程序結(jié)構(gòu),是7.3以前沒(méi)有的。8.1版本又?jǐn)U展了一些函數(shù)。
            在Oracle 9i中雖然支持這些舊的標(biāo)準(zhǔn),不過(guò)Oracle強(qiáng)烈建議使用全新的OCI標(biāo)準(zhǔn)庫(kù)。
             參考OCI文檔中"介紹和升級(jí)內(nèi)容"一節(jié),獲取更多信息。
             
            四、OCI Makefile 介紹

             現(xiàn)在差不多該介紹源代碼了,首先的是Makefile文件,可以說(shuō)成是整個(gè)項(xiàng)目的中心,參
            看例中的文件內(nèi)容。注意頭文件目錄有兩個(gè),庫(kù)文件和Pro*C使用的一樣,還是 libclntsh.so.9.0 ,
            相關(guān)路徑自已調(diào)整。
             這個(gè)Makefile比較簡(jiǎn)單,把前面文章羅列的所有代碼復(fù)制并建立相應(yīng)文件,使用"make all"
            "make clean" 命令,你應(yīng)該能看到如下類似的內(nèi)容: 

            [root@liwei oci]# make clean;
            rm -f OCIDB OCIDB.o OCIException.o Exception.o OCIError.o Main.o
            [root@liwei oci]# make all;
            [OCIDB.o]
            ---------------------
            g++ -g -o OCIDB.o -I/home/ora/ora9/oracle/rdbms/demo -I/home/ora/ora9/oracle/rdbms/public -c OCIDB.cpp

            [OCIException.o]
            ---------------------
            g++ -g -o OCIException.o -I/home/ora/ora9/oracle/rdbms/demo -I/home/ora/ora9/oracle/rdbms/public -c OCIException.cpp

            [Exception.o]
            ---------------------
            g++ -g -o Exception.o -I/home/ora/ora9/oracle/rdbms/demo -I/home/ora/ora9/oracle/rdbms/public -c Exception.cpp

            [OCIError.o]
            ---------------------
            g++ -g -o OCIError.o -I/home/ora/ora9/oracle/rdbms/demo -I/home/ora/ora9/oracle/rdbms/public -c OCIError.cpp

            [Main.o]
            ---------------------
            g++ -g -o Main.o -I/home/ora/ora9/oracle/rdbms/demo -I/home/ora/ora9/oracle/rdbms/public -c Main.cpp

            [link] ... 
            ---------------------
            g++ -g -o OCIDB OCIDB.o OCIException.o Exception.o OCIError.o Main.o -L/home/ora/ora9/oracle/lib -lclntsh

             Makefile相關(guān)知識(shí)可以去Google一下,文章從現(xiàn)在開(kāi)始,就要陸續(xù)介紹一些OCI
            實(shí)質(zhì)性的內(nèi)容了。

            posted on 2011-03-23 00:11 一路風(fēng)塵 閱讀(578) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Oracle
            国内精品伊人久久久久影院对白| 99久久香蕉国产线看观香| 久久精品免费一区二区三区| 国产精自产拍久久久久久蜜| 欧美日韩久久中文字幕| 久久99精品久久久久久动态图| 久久96国产精品久久久| 日韩欧美亚洲综合久久影院Ds | 伊人久久大香线焦综合四虎| 久久精品国产亚洲Aⅴ香蕉 | 亚洲日韩中文无码久久| 精品无码久久久久久久久久| 97久久精品人妻人人搡人人玩| 亚洲国产小视频精品久久久三级| 亚洲国产一成久久精品国产成人综合| 久久久久久综合网天天| 久久综合九色综合精品| 久久久亚洲欧洲日产国码是AV | a高清免费毛片久久| 色综合合久久天天给综看| 996久久国产精品线观看| 区久久AAA片69亚洲| 精品国产婷婷久久久| 久久亚洲国产成人精品性色| 久久婷婷五月综合97色直播| 久久99亚洲网美利坚合众国| 久久人人青草97香蕉| 久久精品?ⅴ无码中文字幕| 国产Av激情久久无码天堂| 久久人人爽人人爽人人爽| 久久久精品日本一区二区三区| 99久久国语露脸精品国产| 久久亚洲美女精品国产精品| 亚洲精品tv久久久久久久久| 久久这里只精品99re66| 久久人人添人人爽添人人片牛牛| 亚洲欧洲精品成人久久曰影片| 婷婷久久五月天| 久久精品国产99国产精品导航| 久久久久亚洲AV无码专区体验| 中文字幕久久亚洲一区|