Hi Guys
Can somebody tell me how to establish a connection between C++ on Unix and Oracle Database which is on the same machine, please ? Please let me know a name of a good book on the same subject. Thanks.
Hmm.. you probably want to look into odbc, and there are any number of books, but I don't know a good one. I use Informix, and they have an embedded sql pre-processor, I think Oracle's is called c* or something like that. This is very easy to use, and I'd try that first of all. As for a good book, I don't know but this thread has been here for awhile so I thought I'd put my 2 cents in.
Good Luck!
mWB. As always, I hope that helped!
Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
The easiest way is the use Oaracle's ProC. I have included a file that will attach to an oracle database using ProC.
/*----------------------------------------------------------------*/
// Name: TestProC.pc
// Date: 7/24/01
//
// Description: This application is a simple Oracle SQL shell that
// can be used to test various SQL statements.
//
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
// This section is used to define variables that will be used by
// Oracle
/*----------------------------------------------------------------*/
long t1;
long t2;
/*----------------------------------------------------------------*/
// Get user's Oracle username and password and open a session
/*----------------------------------------------------------------*/
printf("Enter your USERID: "
scanf("%s",user.arr);
user.len = strlen((const char *)user.arr);
/*----------------------------------------------------------------*/
// execute sql_error function when Oracle returns an error
/*----------------------------------------------------------------*/
EXEC SQL whenever sqlerror do sql_error("Oracle error:"
/*----------------------------------------------------------------*/
// Connect to database
/*----------------------------------------------------------------*/
EXEC SQL connect :user identified by ass;
cout << "\nConnected to ORACLE as user: "
<< (char *)user.arr << endl << endl;
/*----------------------------------------------------------------*/
// Build Oracle SQL statement here. Be sure to precede the statement
// with EXEC SQL. Be sure to check for errors before proceeding
// (sqlca.sqlcode...)
/*----------------------------------------------------------------*/
t1 = clock();
EXEC SQL select new_order.oats_roe_id
into ats_roe_id
from new_order
where new_order.oats_roe_id = 157680;
cout << "Time to process SQL statement: " << t2-t1 << " sec" << endl;
/*----------------------------------------------------------------*/
// Close connection
/*----------------------------------------------------------------*/
Maybe you'll find useful the possibility of calling C functions from Oracle pl/sql too. Search for "external procedures" into Oracle web help if you're interested on it.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.