Re: Pragma Interface "C"
Date: 1997/07/08
Message-ID: <33c3766d.14047999_at_newshost>#1/1
On 8 Jul 1997 16:00:19 GMT, matt_at_beaker.imicro.com (Matthew Benjamin) wrote:
>I heard somewhere that it was possible to use the (Ada-derived)
>PRAGMA INTERFACE "C" directive to declare external C functions, which
>would presumably reside in external libraries on an Oracle server
>system.
>
>I have not seen any official or unofficial Oracle documentation which
>explains how one would do this.
>
The pragma interface "C" is an internal mechanism and is not exposed for
developers to use in the 7.x database. pragma interface "C" can only be used to
call c routines in the Oracle Kernel and only under special circumstances. For
example, if you ever accidently run the dbms_pipe package in a non SYS schema,
you'll find the pragma interfaces stop working (only sys can use it, and only
for functions exported from the kernel)
>Similarly, a recent review of Oracle 8/NCA states that Oracle "now" supports
>"C callouts" (the same mechanism?), but again, no reference was given for this claim.
>
This is documented in the pl/sql reference for Oracle8. Here is a real small example:
CREATE FUNCTION gcd (
-- find greatest common divisor of x and y
x BINARY_INTEGER,
y BINARY_INTEGER)
RETURN BINARY_INTEGER AS EXTERNAL
LIBRARY c_utils
NAME "c_gcd" -- quotes preserve lower case
LANGUAGE C;
The C prototype for c_gcd follows:
sb4 c_gcd(sb4 x_val, sb4 y_val);
You have control over how datatypes and such are mapped as well. A more complex example would be:
CREATE FUNCTION parse (
x IN BINARY_INTEGER,
Y IN OUT CHAR)
RETURN CHAR AS EXTERNAL
LIBRARY c_utils
NAME "c_parse"
LANGUAGE C
CALLING STANDARD PASCAL
PARAMETERS (
x, -- stores value of x x INDICATOR, -- stores null status of x y, -- stores value of y y LENGTH, -- stores current length of y y MAXLEN, -- stores maximum length of y RETURN INDICATOR);
With this PARAMETERS clause, the C prototype becomes
char * c_parse(sb4 *x, sb2 x_ind, char *y, sb4 *y_len,
sb4 *y_maxlen, sb2 *retind);
>Can anyone point me to some information?
>
>
>TIA,
>
>
>Matt Benjamin
>matt_at_imi.imicro.com
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD
http://govt.us.oracle.com/ -- downloadable utilities
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Tue Jul 08 1997 - 00:00:00 CEST