Working with external procedures
Previous  Index  Next

OCL may be used in your external procedures to manipulate data and call stored procedures. This is all done in a single service context that is passed as a parameter to external procedures.
For example the following declaration of external procedure:

CREATE OR REPLACE
PROCEDURE MyExtProc (x BINARY_INTEGER, y VARCHAR2)
  AS EXTERNAL
  NAME "C_demoExternal"
  LIBRARY MyLib
  WITH CONTEXT
  PARAMETERS(CONTEXT, x INT, y STRING); 

and this declaration of MyLib library associated with external DemoLib.DLL library:

CREATE LIBRARY MyLib
  AS 'C:\MyDLLs\DemoLib.DLL';

will require the following declaration of C function C_demoExternal in DemoLib.DLL:

#include "ocl.h"

extern "C" int __declspec(dllexport)
externalProcedure(OCIExtProcContext* context, int x, char* y)
{
    OraConnection connection;
    
    initExtProcSession(context, connection);
    
    OraQuery query(connection);

    ...
}

To associate connection object with the context handle use initExtProcSession global function. Then you may create instances of other classes such as OraCommand and OraQuery and execute your SQL and PL/SQL statements as you would normally do in client applications.

Using external procedures this way gives your applications the following benefits:
·Faster processing since external procedures are located on server side.  
·Reduced network round-trip.  
·Reusable code is even more reusable as all clients work with only one instance of external procedures.  
·Maintenance is only required on server side.  

See Also

ExtProc demo project


OCL | Using OCL | Index