Include Oracle header files after jagpublic.h, as in the example below:
#include <jagpublic.h> #include "oratypes.h" #include "ocidfn.h" #ifdef __STDC__ #include "ociapr.h" #else #include "ocikpr.h" #endif #include "ocidem.h"
Most Connection Manager routines require the address of a CM_CACHE handle as a parameter. The cache handle allows your code to refer to a specific cache that is defined in EAServer Manager. The routines JagCmGetCachebyName or JagCmGetCachebyUser retrieve cache handles.
OCI 7.x uses an Lda_Def structure to represent a database connection. The JagCmGetConnection routine returns the address of an Lda_Def structure.
The example below retrieves an Lda_Def structure, executes a statement using the connection, then returns the connection to the cache.
#include <jagpublic.h> #include "oratypes.h" #include "ocidfn.h" #ifdef __STDC__ #include "ociapr.h" #else #include "ocikpr.h" #endif #include "ocidem.h" Cda_Def cda; Lda_Def *lda; #define USERID "system" #define PASSWD "manager" #define DATASOURCE "OCITEST" /* Connect to ORACLE. */ cache = NULL; ret = JagCmGetConnection(&cache, USERID, PASSWD, DATASOURCE, "OCI_7", (void*)&lda, JAG_CM_FORCE); /* Open a cursor, parse stmt, execute, close cursor */ oopen(&cda, lda, (text *) 0, -1, -1, (text *) 0, -1); oparse(&cda, sql_statement, -1, FALSE, 2); ... if (oexec(&cda)) oci_error(&cda); ... if (oclose(&cda)) oci_error(&cda); /* release connection */ ret = JagCmReleaseConnection(&cache, USERID, PASSWD, DATASOURCE, "OCI_7", (Lda_Def *)lda, JAG_CM_UNUSED);
Copyright © 2005. Sybase Inc. All rights reserved. |