Note: The following procedures are tested through the delphi7+oracle9i
1, first use Delphi to prepare a DLL program, of course, with VB,VC other languages can also,
I recently used Delphi, so the following DLLs using Delphi programming:
PROJECT1.DPR Engineering Documents
Library Project1;
Uses
Sysutils,
Classes,
Unit1 in ' Unit1.pas ';
{$R *.res}
Exports
Dlltest;
Begin
End.
Unit1.pas interface function Implementation file
Unit Unit1;
Interface
function Dlltest (a,b:double): double; Cdecl interface functions
Implementation
function Dlltest (a,b:double): double; Cdecl interface functions
Begin
Result:=a*b;
End
End.
2, will compile the generated Project1.dll copy to the $oracle_home/bin path, I $oracle_home=c:/oracle/ora92
So copy the Project1.dll to the c:/oracle/ora92/bin/path.
3, the ORACLE database to add a library name "Mylib"
Create or replace library Mylib
As ' C:/oracle/ora92/bin/project1.dll ';
4, the ORACLE database to add a function name "Mytest1"
CREATE OR REPLACE FUNCTION mytest1 (a double precision,b double PRECISION) return double PRECISION as
LANGUAGE C NAME "Dlltest"
LIBRARY Mylib
PARAMETERS (a double,b DOUBLE,
return DOUBLE);
5. Test
Select Mytest1 (3.51,8.2) from dual;
------------return 28.782
6, to this simple example to complete, in fact, this is a simple example, the actual application needs to be done according to the requirements,
I do this example is just for you to open the way, the actual application also need to refer to Oracle Help documentation.
SOURCE program and script download address:
http://www.cnoug.org/attachment.php?aid=20557