OLE C++ In DLL Exception through extproc.exe

From: DevMan <devman_at_firststopinternet.com>
Date: 28 Feb 2003 04:10:39 -0800
Message-ID: <9e476c2b.0302280410.4d13ce33_at_posting.google.com>



Can somebody please help, this is driving me insane.

The following code is called within a DLL (Written in Visual Studio.NET), it works but when the DLL is unloaded it crashes.

I call it through PL/SQL. (function defined at end of this email).

(Unhandled exception at 0x77f525d9 in extproc.exe: 0xC0000005: Access violation reading location 0x00000010)

extern "C" __declspec(dllexport) int OraTest( ) {

	int total = 0;
	ODatabase	db;
	ODynaset	odyn;

	OStartup( );
	
	db.Open( "ora", "scott", "tiger" );

	odyn.Open(db, "select sum(sal) CNT from emp");
	
	odyn.GetFieldValue("CNT", &total);

	odyn.Close(); 
	db.Close();

	OShutdown();

	return total;

}

I can call this code over and over while the DLL is loaded by the SQL session, but as soon as I quit the sql session, extproc.exe crashes.

Can anyone help me with this?, or explain what may be going on?

If I remove the db. and odyn. lines then it works fine, obviously not doing much!!, as soon as I put the db stuff back in it crashes.

It appears I am handling the db destructor in the correct way (db.Close()) as well, and valid results are returned from the function.

The PLSQL code is as follows:

create or replace library jclib as 'D:\my documents desktop\My Documents\Visual
Studio Projects\dm3\debug\dm3.dll';
/

create or replace function testORA return binary_integer as external library jclib name "OraTest" language C;
/

SHOW ERRORS
/

SELECT testORA() from dual
/
Received on Fri Feb 28 2003 - 13:10:39 CET

Original text of this message