Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: OCI (7.3) programming Q
Yikes! I forgot to do an oexec(&cda); after the oparse(). Found out myself today. It's working now.
Christoph Kukulies <kuku_at_gil.physik.rwth-aachen.de> wrote:
: I had written an OCI interface application under 8.0.5 and higher
: and it worked fine using the newer OCI interface API.
: Since I had this problem with some customers who are using
: 7.3.3 I tried to rewrite my application for the older interface API.
: Somehow it doesn't work. I don't get any errors. The connection
: to the database seems to be made. I'm even observing disk activity on
: the server but when my database load finishes (via execution of SQL statements
: over the network) no table is created. Nothing is entered. The database is
: empty. Also the load process is suspicially fast.
: Somehow I must be doing wrong - maybe with the understanding of DEFERED_PARSE.
: Can someone experienced with OCI help me?
: Here is my interface. It looks a bit dumb with the big buffer being filled
: but that's for compatibility with the upper layer.
: --
: Chris Christoph P. U. Kukulies kuku_at_gil.physik.rwth-aachen.de
: /*-------------- Oracle 7.3 Version C. Kukulies 27.7.1 ---------------------*/
: #include <stdio.h>
: #include <stdlib.h>
: #include <ctype.h>
: #include <string.h>
: #include "oratypes.h"
: /* LDA and CDA struct declarations */
: #include <ocidfn.h>
: #ifdef __STDC__
: #include <ociapr.h>
: #else
: #include <ocikpr.h>
: #endif
: /* demo constants and structs */
: #include <ocidem.h>
: FILE *db_log;
: /*----------------------------------------------------------------------------*/
: #define DB_BUF 8000
: static char db_buf[DB_BUF];
: /*----------------------------------------------------------------------------*/
: void err_report();
: void insert_data();
: void do_exit();
: /* oparse flags */
: #define DEFER_PARSE 1
: #define NATIVE 1
: #define VERSION_7 2
: #define HDA_SIZE 256
: /* exit flags */
: #define OCI_EXIT_FAILURE 1
: #define OCI_EXIT_SUCCESS 0
: Cda_Def cda;
: Lda_Def lda;
: ub4 hda[HDA_SIZE/sizeof(ub4)];
:
: /*----------------------------------------------------------------------------*/
: DBConnect (char *server, char *username, char *password)
: {
: if (olog(&lda, hda, username , -1, password, -1,
: (text *)server, -1, OCI_LM_DEF)) {
: err_report((Cda_Def *)&lda);
: do_exit(OCI_EXIT_FAILURE);
: }
: db_buf[0]=0;
: if (oopen(&cda, &lda, (text *) 0, -1, -1, (text *) 0, -1)) /* open */
: {
: err_report(&cda);
: do_exit(OCI_EXIT_FAILURE);
: }
: }
: /*----------------------------------------------------------------------------*/
: DBDisconnect ()
: {
: printf("Disconnecting...\n");
: if (oclose(&cda)) /* close cursor */
: {
: fprintf(stderr, "Error closing cursor 1.\n");
: do_exit(OCI_EXIT_FAILURE);
: }
: if (ologof(&lda)) /* log off the database */
: {
: fprintf(stderr, "Error on disconnect.\n");
: do_exit(OCI_EXIT_FAILURE);
: }
: }
: /*----------------------------------------------------------------------------*/
: DBSql (int lineno, char *where)
: {
: #ifdef DEBUG
: printf("[%s]",db_buf);
: #endif
: if (oparse(&cda, db_buf , (sb4) -1 , DEFER_PARSE, /* parse */
: (ub4) VERSION_7))
: {
: err_report(&cda);
: do_exit(OCI_EXIT_FAILURE);
: }
: db_buf[0]=0;
: }
: /*----------------------------------------------------------------------------*/
: DBOut (char *string, char *where)
: {
: if (strlen(db_buf) + strlen (string) < DB_BUF)
: {
: strcat (db_buf, string);
: return (0);
: }
: else
: {
: fprintf (db_log, "ERROR - buffer overflow in %s\n", where);
: exit(1);
: }
: }
: void do_exit(status)
: eword status;
: {
: if (status == OCI_EXIT_FAILURE)
: printf("\n Exiting with FAILURE status %d\n", status);
: else
: printf("\n Exiting with SUCCESS status %d\n", status);
: exit(status);
: }
: void err_report(cursor)
: Cda_Def *cursor;
: {
: sword n;
: text msg[512]; /* message buffer to hold error text */
: if (cursor->fc > 0)
: printf("\n-- ORACLE error when processing OCI function %s \n\n",
: oci_func_tab[cursor->fc]);
: else
: printf("\n-- ORACLE error\n");
: n = (sword)oerhms(&lda, cursor->rc, msg, (sword) sizeof msg);
: fprintf(stderr, "%s\n", msg);
: }
-- Chris Christoph P. U. Kukulies kuku_at_gil.physik.rwth-aachen.deReceived on Tue Aug 07 2001 - 05:32:52 CDT