Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How do I link a c-program to oracle8?§

Re: How do I link a c-program to oracle8?§

From: Gennaro Napolitano <Gennaro.Napolitano_at_sbsitalia.it>
Date: Thu, 06 May 1999 10:33:00 +0200
Message-ID: <373153BC.AFEFDC2B@sbsitalia.it>


Fredde wrote:
>
> Hi,
>
> How do I link a program written in c to a procedure or function in PS-SQL
> / Oracle8?
>
> / Fredrik Antonsson Ronneby, Sweden

In order to call an external procedure from a stored procedure you need:

  1. Create a dll or a shared object, depending on the OS;
  2. Create an Oracle library: To create an Oracle library you should have the 'CREATE ANY LIBRARY' privileges, then you can create a your own alias library using the following syntax: CREATE LIBRARY library_name { IS | AS } 'file_path'; You must specify the full path to the Shared object or dll.

3)Registering the external procedure:

      Before you can call the external procedure, you must register it. 
      That means, you must tell PL/SQL where to find the procedure, how
to call 
      it and what to pass it, using the following syntax:
     
      CREATE FUNCTION Function_Name(
	Input_1 IN CHAR,
	Input_2 IN CHAR)
      RETURN BINARY_INTEGER AS EXTERNAL 
	LIBRARY library_name
	NAME DLL_Name(shared object name)
	LANGUAGE C;
     
      Now you are able to call the external procedure 'Function_Name'
from a 
      PL/SQL block using the following example:

      DECLARE 
	 Input_1 VARCHAR2(32);
	 Input_2 VARCHAR2(32);
	 rc 	BINARY_INTEGER;
      BEGIN
	 Input_1 := 'Test_1';
	 Input_2 := 'Test_2';
	 rc      := Function_Name(Input_1, Input_2);
      END;

/

For further information see PL/SQL User's Guide and Reference, paragraph 'External Procedure'.

Hope this help
Ciao Gennaro

--
"Buongiorno signor De Filippo, qui e' la Televisione". "Va bene, aspetti che le passo il frigorifero" disse Eduardo De Filippo. Received on Thu May 06 1999 - 03:33:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US