Newbie for External Procedures

Newbie for External Procedures

Post by Raymond K.W. La » Sat, 05 Sep 1998 04:00:00



Oracle 8 has a new feature, External Procedure, for server-side PL/SQL.
Does it mean that PL/SQL could now use OS or third party dynamic
link libraries even its are not written specific for Oracle Server ?

- Raymond

 
 
 

Newbie for External Procedures

Post by Finn Ellebaek Nielse » Mon, 07 Sep 1998 04:00:00


Yes, as I posted as a response to another question:

In Oracle8 you can call external 3GL code in a dynamically linked library
(DLL or shared object). So you just write a library in C doing what you want,
ie in your case a host function taking the command line as input argument.
And that function will be callable from PL/SQL.

So what you have to do is more or less:

1. Write C code in host.c: int host(char *command) { ... }.
2. Compile C code to DLL or shared object, eg c:\winnt\system32\host.dll.
3. "create or replace library host as 'c:\winnt\system32\host.dll';"
4. "create or replace function host(command in varchar2) return pls_integer
    is external
    library host
    name "host"
    language c
    calling standard pascal
    parameters (host string, return long);"

Hope this helps.

Ciao,

Finn


> Oracle 8 has a new feature, External Procedure, for server-side PL/SQL.
> Does it mean that PL/SQL could now use OS or third party dynamic
> link libraries even its are not written specific for Oracle Server ?

> - Raymond

--
----------------------------------------------------------------------
 Ellebaek Consulting ApS         Finn Ellebaek Nielsen
 Niels Ebbesens Vej 9, 3. th.    Managing Director, Senior Consultant

 Denmark                         +45 20 32 49 25
----------------------------------------------------------------------
                  "Where do you want to GPF today?"

 
 
 

Newbie for External Procedures

Post by Finn Ellebaek Nielse » Mon, 07 Sep 1998 04:00:00


Yes, as I posted as a response to another question:

In Oracle8 you can call external 3GL code in a dynamically linked library
(DLL or shared object). So you just write a library in C doing what you want,
ie in your case a host function taking the command line as input argument.
And that function will be callable from PL/SQL.

So what you have to do is more or less:

1. Write C code in host.c: int host(char *command) { ... }.
2. Compile C code to DLL or shared object, eg c:\winnt\system32\host.dll.
3. "create or replace library host as 'c:\winnt\system32\host.dll';"
4. "create or replace function host(command in varchar2) return pls_integer
    is external
    library host
    name "host"
    language c
    calling standard pascal
    parameters (host string, return long);"

Hope this helps.

Ciao,

Finn


> Oracle 8 has a new feature, External Procedure, for server-side PL/SQL.
> Does it mean that PL/SQL could now use OS or third party dynamic
> link libraries even its are not written specific for Oracle Server ?

> - Raymond

--
----------------------------------------------------------------------
 Ellebaek Consulting ApS         Finn Ellebaek Nielsen
 Niels Ebbesens Vej 9, 3. th.    Managing Director, Senior Consultant

 Denmark                         +45 20 32 49 25
----------------------------------------------------------------------
                  "Where do you want to GPF today?"
 
 
 

1. External Procedures (newbie)

Hello,
I'm trying to call an external C procedure or function from Oracle on a Sun
machine. Without much succes.

I have created a dynamic shared library of a C routine and placed it in
"/usr/lib". This library is callable from other C programs.
Then I create an Oracle library for the C library with the
"CREATE LIBRARY mylib AS '/usr/lib/mylib'
this returns succesfully.

But when I try to create the Oracle procedure:
CREATE PROCEDURE myProc AS EXTERNAL
EXTERNAL LIBRARY mylib
NAME 'myCProc'
LANGUAGE C;

it returns: warning: procedure created with compilation errors.

and if I try to call it by typing in myProc on the SQLPLUS prompt it
returns: unknown command

And even if I try to type this in directly from the manual
PROCEDURE myProc IS
BEGIN
    SELECT * FROM test
END myProc;

I get an error: "Invalid SQL statement"

Config:
SUN: SunOS 5.7
Oracle: Ver. 8.1.6.0.0

Help!
Thanks

2. filemaker 'freezing'

3. Unresolved external in external procedure

4. ps_dump -a

5. Pass a CLOB to an external procedure and pass changes back to calling procedure

6. Year 2000 date problem

7. External Procedure or Java Stored Procedure

8. dbreindex, statistics, and sp_recompile

9. External Stored Procedure vs. SQL Stored Procedure

10. Data access to external files (newbie)

11. Newbie, How do I call external program/function from a SQL 2000 UDF

12. Newbie Question: Insert Text from External File