Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling an Oracle Function

Status
Not open for further replies.

mbames

Programmer
Jun 5, 2003
29
GB
Hi,

I am new to both Oracle and C++, so this many be a simple problem, but I would appreciate your help with it!

I am using the basic code found at:
However that I need to do is insert data into one table, retrieve that tables autonumber field (I was going to use <sequence>.currval) and return it via an Oracle function. I have been able to call my oracle function via a small test script in SQL*Plus, but when I am not sure how to call it from with in my C++ code. I have sucessfully been able to call normal oracle procedures, but when I use the name of a function, the ODBC link reports back saying unknown procedure.

Any hints?!

Cheers,
Matt
 
If you can test it with SQLPlus I assume you have added an ODBC source. To connect to the database, you will need to have a connect string and send it to a CDatabase class


virtual BOOL OpenEx( LPCTSTR lpszConnectString, DWORD dwOptions = 0 );

lpszConnectString

Specifies an ODBC connect string. This includes the data source name as well as other optional information, such as a user ID and password. For example, &quot;DSN=SQLServer_Source;UID=SA;PWD=abc123&quot; is a possible connect string. Note that if you pass NULL for lpszConnectString, a Data Source dialog box will prompt the user to select a data source.

You can then create a CRecordset with this CDatabase pointer

CRecordset( CDatabase* pDatabase = NULL);

OR

You can just execute straight sql from the CDatabase.

I hope this gets you started.

Matt
 
Are you using {Oracle ODBC Driver} or {Microsoft ODBC Driver To Oracle}?

Ion Filipski
1c.bmp


filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top