Perl Cd Bookshelf [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Perl Cd Bookshelf [Electronic resources] - نسخه متنی

Mark V. Scardina, Ben ChangandJinyu Wang

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






Setting Up the C++ OCI XML Application Environment

To build C++ XML database applications, you need to set up the necessary headers and libraries and make files. Fortunately, you already have these items if you have installed the companion CD and specified as your destination directory $ORACLE_HOME on Unix or %ORACLE_HOME% on Windows. You will be using both the OCI and XDK header files for this application. You will not be using the OCCI header files.


The OCI XML Application Headers


The headers in Oracle Database 10g are installed into your Oracle Home when you perform the initial companion CD installation. Once you have done this, you will have two directories that include the necessary header files: $ORACLE_HOME/rdbms/demo and $ORACLE_HOME/xdk/ include on Unix, and %ORACLE_HOME%/rdbms/demo and %ORACLE_HOME%/xdk/include on Windows. The following is the application header file that lists the required Oracle headers along with the application functions:

 #ifndef STDIO 
#include <stdio.h>
#endif
#ifndef STDLIB
#include <stdlib.h>
#endif
#ifndef STRING
#include <string.h>
#endif
extern "C" {

#ifndef OCIAP_ORACLE
#include <ociap.h>
#endif
}
extern "C" {
#ifndef XML_ORACLE
#include <xml.h>
#endif
}
#ifndef XMLCTX_CPP_ORACLE
#include <xmlctx.hpp>
#endif
/* constants */
#define MAXBUFLEN 2000
#define SCHEMA "SYS"
#define TYPE "XMLTYPE"
/* classes */
class ociapi {
public:
/* constructors and destructors */
ociapi();
~ociapi();
/* member functions */
sb4 init_env_handle();
sb4 connect_server( text* user, text* password);
void disconnect_server( boolean tab_exists);
void cleanup();
sb4 select_and_query(text* select_stmt, text* xpathexp);
sb4 select_from_doc( OCIXMLType* xml, text *xpathexpr);
/* get member functions for private variables */
OCIEnv* getEnv() const;
private:
/* OCI Handles and Variables */
OCIEnv *envhp;
OCIServer *srvhp;
OCISvcCtx *svchp;
OCIError *errhp;
OCISession *authp;
OCIStmt *stmthp;
};

/* functions */
void checkerr( OCIError* errhp, sword status);
/* generic functions */
template< typename TCtx, typename Tnode>
sb4 doXPath( TCtx* ctxp, DocumentRef< Tnode>& doc_ref,
char* xpath_exp);
/*----------------- End of Functions Declaration -----------------*/

In examining this file, first note that there are two Oracle C header files, xml.h and ociap.h. These contain the C XML APIs and OCI APIs, respectively. The xmlctx.hpp file is the header file for the constructor class for OCI XML initialization. We discuss the functions when we get to the code throughout the chapter.


The OCI and C++ XML Application Libraries


OCI applications are dynamically linked on both Unix and Windows using libclntsh.so, located in $ORACLE_HOME/lib32 on Unix, and oci.lib plus ociw32.lib, located in %ORACLE_HOME%\ oci\lib\Msvc on Windows. In the past the Solaris library has been in the lib directory, but since Oracle Database 10g is now only a 64-bit release, the 32-bit libraries are located in their own directory. On Windows you also need to link with the user32.lib, kernel32.lib, msvcrt.lib, advapi32.lib, oldnames.lib, and winmm.lib Windows libraries.

The OCI libraries do not contain the XML APIs; therefore, you also need to link with libxml10.a on Unix and oraxml10.lib on Windows, which include both the C and C++ XML APIs. The Unix library is not a shared one like the OCI library and thus the objects you need will be pulled into your executable.

/ 218