Oracle External Procedures - Page 3
|Oracle External Procedures|
Installing your ExtProc library on Oracle
Copy the binary to a directoy that O/S user 'oracle' has access to, referred to below as <LIBDIR>.
Log in to sqlplus as the appropriate user and create an Oracle library object:
- SQL> CREATE library libhostcmd AS '<LIBDIR>/libhostcmd.so';
- 2 /
- Library created.
Note that <LIBDIR> should be an absolute path and not the relative path.
Create a function to the library. This is the depricated way to do it (but I like it more):
- SQL> CREATE OR REPLACE FUNCTION hostcmd(p_cmd IN varchar2)
- 2 RETURN binary_integer
- 3 AS external name "hostcmd"
- 4 library libhostcmd
- 5 LANGUAGE C
- 6 parameters (p_cmd STRING, RETURN INT);
- 7 /
- FUNCTION created.
Set up access rights (Warning: see NOTES section below):
- SQL> GRANT execute ON hostcmd TO public;
Optional: Make a synonym if you have the privileges
- SQL> CREATE public synonym hostcmd FOR hostcmd
The binary does not actually need to exist when the library object is created. Binding to the binary library file only occurs at run time.