Click here to Skip to main content
Licence 
First Posted 27 Sep 2002
Views 96,854
Bookmarked 32 times

C++ wrapper for Oracle's OCI Interface

By | 27 Sep 2002 | Article
This article will provide a cross platform C++ wrapper for Oracle's OCI interface.
 
Part of The SQL Zone sponsored by
See Also

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

About the Author

lihaijian

Web Developer

United States United States

Member

6 years Programer With VC++

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Questionlinking error :( Pinmembersu_r00t5:19 5 Feb '09  
Generalmy email had changed!w Pinmemberyt_lhj21:41 29 Apr '08  
QuestionRe: insert? Pinmemberzuzulica11:03 3 Jan '07  
Questioninsert? Pinmembercata_100010:57 24 Nov '06  
GeneralORACLE/ODBC PinmemberM_Nuaimi13:23 25 Apr '06  
GeneralOracle OCI library Pinmembermaacha18:00 13 Apr '05  
GeneralRe: Oracle OCI library PinmemberMichael B Pliam20:34 22 Feb '07  
GeneralCLOB Datatype PinmemberLeong Hoe Wai19:26 18 Aug '04  
Questionhow i can do insert? Pinmemberandresfecas14:03 26 Apr '04  
GeneralUnable to link OCI containing library PinmemberVijaylakshmi19:10 18 May '03  
GeneralRe: Unable to link OCI containing library PinmemberThoMay19:16 2 Mar '05  
Generalmemory bug in source code Pinmemberscy0:33 1 Mar '03  
GeneralRe: memory bug in source code Pinmemberscy14:51 6 Jan '04  
GeneralA simple linklist; PinmemberMadmaximus4:38 16 Dec '02  
GeneralRe: A simple linklist; Pinmemberyt_lhj18:14 16 Dec '02  
QuestionHow can I do ?? PinsussShanGuohui3:11 24 Oct '02  
QuestionHow do you handle two connections ? PinmemberMiroslav Rajcic21:03 29 Sep '02  
AnswerRe: How do you handle two connections ? Pinmemberlihaijian21:30 29 Sep '02  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 28 Sep 2002
Article Copyright 2002 by lihaijian
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid