Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: External Procedure using VC++
Never mind. I figured it out myself.
Anyway, for future reference, if you have to use VC++ in an external procedure here's an example:
/* Ext02.c - write to a text file from an Oracle stored external procedure
1. Create a new project and select Win32 Dynamic-Link Library, 2. Step 1 - select "An empty DLL project", and click Finish button. 3. [Note there is no need to use a DllMain() function.] 4. Create a new C++ source file, enter your code, 5. Change the extension of your code from a .cpp to .c 6. IMPORTANT - funcs must be preceeded by __declspec(dllexport) 7. compile. 8. Create library in Oracle and compile it, eg., CREATE or replace LIBRARY Ext02_lib IS 'c:\Ext02.dll'; 9. Create stored procedure, eg., procedure DT_CallDllSample ( p_msg in varchar2 ) as external library Ext02_lib name "Write" parameters ( p_msg ) language C; 10. Call your stored procedure, eg., begin dt_calldllsample( 'this is a test' ); end;
#include <windows.h>
#include <stdio.h>
__declspec(dllexport)
void Write( char * string ) {
FILE * fp;
fp = fopen( "c:\\ExternProc1.txt", "a+" );
fwrite( string, 1, strlen( string ), fp );
fclose( fp );
}
"Christine" <***ccookga_at_mindspring.com> wrote in message
news:8gbo5m$12r$1_at_slb6.atl.mindspring.net...
> Anyone got an example of how to create external procedures using Visual
C++.
> The Oracle docs have gotten me most of the way.
>
>
Received on Tue May 23 2000 - 00:00:00 CDT