Solved

Oracle C++ library

Posted on 2004-09-25
9
992 Views
Last Modified: 2013-12-12
hi friends,
              I want to access oracle database through C++ i.e i want to make connection create,delete and access different tables.
              When i installed oracle server on linux i have some demo codes already provided by oracle.
              First these code is not executing because of some library is not present(undefined reference)
               Secondly  Do i require a oracle client to install
               Will you  please give some source codes for oracle connection and accessing database
thanx in advance
0
Comment
Question by:jassy_shah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 7

Expert Comment

by:BobMc
ID: 12172995
If you want to access an Oracle database, the simplest way is to use the OCCI for C++.
This should be an option when you install the Oracle client.

Typical use is (pulled straight from the Oracle docs)

const string userName = "SCOTT";
const string password = "TIGER";
const string connectString = "";

Environment *env = Environment::createEnvironment();
{
   Connection *conn = env->createConnection(userName, password, connectString);
   Statement *stmt = conn->createStatement("SELECT blobcol FROM mytable");
   ResultSet *rs = stmt->executeQuery();
   rs->next();
   Blob b = rs->getBlob(1);
   cout << "Length of BLOB : " << b.length();
   .
   .
   .
   stmt->closeResultSet(rs);
   conn->terminateStatement(stmt);
   env->terminateConnection(conn);
}
Environment::terminateEnvironment(env);
0
 
LVL 11

Expert Comment

by:mohammadzahid
ID: 12174842
Yes, you need atleast Oracle client installed on the system from where you are making connection and have the oci libraries defined on that box.
If oci libraries are not defined then you will get errors at the linking stage. Please refer to Oracle Technology Network site and download Oracle OCI C++ Guide.

0
 

Author Comment

by:jassy_shah
ID: 12206735
Yes i do appreciate ur comments
The programs which i am executing are present on the server itself so i dont think so i require a oracle client installed this is because i already have OCCI library when i install server.
 
        Suppose i install oracle client whether oracle libraries will also be installed with that. Also i am installing client on server itself.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:BobMc
ID: 12207280
Yes, you should install a separate client on your server, so you can patch the application interface without affecting your database in the future.

You should get an option to install the libraries with the client  - either via the custom install, or the programme one (cant remember the actual name)
0
 
LVL 11

Expert Comment

by:mohammadzahid
ID: 12210211
Please verify the server library path that it contains the correct location of the OCI libraries.

Please provide some more details:

- Oracle database version?
- C++ environment (Example : Visual C++, etc...) ?
- Server operating system?
- Client operating system?


0
 

Author Comment

by:jassy_shah
ID: 12234936
Oracle version:9i
C++ environment on Linux platform
client and server (redhat linux 9.0)

0
 
LVL 11

Expert Comment

by:mohammadzahid
ID: 12235008
Does the library path contain correct path where Oracle libraries are located?
On linux what C++ IDE are you using to program, compile and link your program to Oracle database?



0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12511950
PAQed - no points refunded (of 50)

modulo
Community Support Moderator
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Creation date for a PDB 5 63
how to double quote a string for an inline sql statement. 8 95
Checking for column width 8 40
Oracle Errors 11 52
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question