Not able to call dll through PL /SQL
-
Hi, I am trying to call one dll inside pl/sql, which I have prepared though vc++. The dll works fine when I call it from any other vc++ applciation and hence tested but it's not working in the pl/sql Although I tried to test my pl/sql procedure with some windows default dll calling them from the procedure, in that case it worked fine. Can you please help me with any hint. I have not used lib file of my dll any where. Could this be the reason? Thank you
With Regards Neeraj Sinha
-
Hi, I am trying to call one dll inside pl/sql, which I have prepared though vc++. The dll works fine when I call it from any other vc++ applciation and hence tested but it's not working in the pl/sql Although I tried to test my pl/sql procedure with some windows default dll calling them from the procedure, in that case it worked fine. Can you please help me with any hint. I have not used lib file of my dll any where. Could this be the reason? Thank you
With Regards Neeraj Sinha
Disclaimer: I'm no expert on Oracle. Generally, when you can't call a function in a DLL from another programming language, it's due to decorated function names, also called 'name-mangling'. The C++ compiler encodes the types of the function's parameters in the name it records in the DLL, because the linker and OS loader match functions by name only, there is no space for parameter types. The types are needed to support overloading. If you open a Visual Studio command prompt (2003 and later; for VC6 open a command prompt and run C:\Program Files\Microsoft Visual Studio\VC98\Bin\vcvars32.bat) and run
dumpbin /exports
on your DLL, you will probably see that the names start with a ? and end with @@ and a bunch of letters and @ symbols. That means they're decorated names. To force undecorated names, the simplest thing to do is to tell the C++ compiler that you want C compatibility. You do this by addingextern "C"
to the start of the function declaration. You should also check which calling convention Oracle requires, to ensure that the stack is set up correctly for calling the function, and cleaned up correctly when it returns.DoEvents: Generating unexpected recursion since 1991
-
Hi, I am trying to call one dll inside pl/sql, which I have prepared though vc++. The dll works fine when I call it from any other vc++ applciation and hence tested but it's not working in the pl/sql Although I tried to test my pl/sql procedure with some windows default dll calling them from the procedure, in that case it worked fine. Can you please help me with any hint. I have not used lib file of my dll any where. Could this be the reason? Thank you
With Regards Neeraj Sinha
Workflow in short: - create the procedure in vc++ - remember to export the procedure explicitly using DLLEXPORT - build the dll - place it in oracle_home/bin folder - connect to oracle - create a library XYZ pointing dll using CREATE LIBRARY statement - create PL/SQL front end using CREATE FUNCTION and defining EXTERNAL LIBRARY XYZ For more information refer to Oracle Database Platform Guide Hope this helps, Mika