Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

C++ wrapper for Oracle's OCI Interface

0.00/5 (No votes)
27 Sep 2002 1  
This article will provide a cross platform C++ wrapper for Oracle's OCI interface.

Introduction

With this C++ wrapper, you can easily do the following:

  • Connect/disconnect to an Oracle server;
  • Execute SQL select/insert/update/delete commands;
  • Store the query result in a simple linked list;

This project is a cross platform implementation.

class  ObList ;
class  Record ;
class  RecordSet;
int Connect();
int Connect(char *user, char *pass, char *service);
void DisConnect();
int ExecCommand(char* cmdbuf);

Examples:

#include <stdio.h>

#include "dbclient.h"


int main(int argc, char* argv[])
{
    Connect();

    printf("Connect OK.\n");
    RecordSet set;
    set.Open("select * from EMP");
    for(int k=0;k<set.GetRecordsCount();k++)
    {
        Record *pRec=set.GetRecord(k);
        for(int l=0;l<pRec->GetFieldsCount();l++)
        {
            printf("%s",pRec->GetFieldValue(l));
            if(l==(pRec->GetFieldsCount()-1))
                printf("\n");
            else
                printf("\t");
        }
    }
    DisConnect();
    return 0;
}

If you are interested in this article, and want to get details, contact me at lihaijian@sina.com or ema13@dongfang-china.com.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here