Hi,
I have a dll which can be called from either c/c++ or VB. Can any one help me how to call the same dll Using Oracle.
Regards,
Nageswara Rao
Printable View
Hi,
I have a dll which can be called from either c/c++ or VB. Can any one help me how to call the same dll Using Oracle.
Regards,
Nageswara Rao
Not a problem as long as your server is running on NT/2000.
You can call it using EXTPROC but it is easier to get hold of the COM automation stuff from OTN:
http://otn.oracle.com/software/tech/...o/content.html
This hides alot of the rubbish and makes the code look simpler. It's just like most Oracle interfaces. Get a handle to the DLL, define the methods you wish to interact with, define any parameters and bang!
I've used it a couple of times in previous jobs and never had any problems. If you've used the Foreign Function Interface in Oracle Forms you'll find it very similar!
Cheers
Tim...
Hi.
I've just knocked something up to show you:
I've made a DLL referenced using 'HostCommand.clsHostCommand' that contains:
Sub HostCommand(sCommand As String)
Dim result As Double
result = Shell(sCommand, vbHide)
End Sub
The I ran the ORACLE_HOME\com\comwarap.sql to create all the COM cartridge stuff.
Then I created the following PL/SQL:
CREATE OR REPLACE PROCEDURE HostCommand(p_command IN varchar2) IS
v_dummy binary_integer;
v_app binary_integer:=-1;
v_i binary_integer;
v_err_src varchar2(255);
v_err_desc varchar2(255);
v_err_helpfile varchar2(255);
v_err_helpid binary_integer;
BEGIN
v_i := ORDCOM.CreateObject('HostCommand.clsHostCommand', 0, '', v_app);
IF v_i != 0 THEN
ORDCOM.GetLastError(v_err_src, v_err_desc, v_err_helpfile, v_err_helpid);
Dbms_Output.Put_Line(v_err_src);
Dbms_Output.Put_Line(v_err_desc);
Dbms_Output.Put_Line(v_err_helpfile);
ELSE
ORDCOM.InitArg();
ORDCOM.SetArg(p_command, 'BSTR');
v_i := ORDCOM.Invoke(v_app, 'HostCommand', 1, v_dummy);
IF v_i != 0 THEN
ORDCOM.GetLastError(v_err_src, v_err_desc, v_err_helpfile, v_err_helpid);
Dbms_Output.Put_Line(v_err_src);
Dbms_Output.Put_Line(v_err_desc);
Dbms_Output.Put_Line(v_err_helpfile);
END IF;
END IF;
v_i := ORDCOM.DestroyObject(v_app);
END HostCommand;
/
Finally call it like:
EXEC HostCommand('Something.exe');
I know it's a crap example, but you get the idea. There are some examples in the ORACLE_HOME\com\demos directory.
Remember, the extproc process remains until the session ends. If you try to do anything with the DLL before the session ends you'll get a sharing violation.
Good Luck.
comwrap.sql not comwarap.sql
Spot the crappy typist :)
Hi Tim,
Thanks for the information.
Regards,
Nageswara Rao