Re: Looking for examples that call C functions from PL/SQL!

From: Thomas Kyte <>
Date: Thu, 12 Aug 1999 11:12:27 GMT
Message-ID: <>

A copy of this was sent to "Dirk Bellemans" <Dirk.Bellemans_at_skynet.belgium> (if that email address didn't require changing) On Thu, 12 Aug 1999 08:03:56 +0200, you wrote:

>Yass Khogaly wrote in message <7n7vgj$538$>...
>> long __declspec(dllexport) OutputString(context ,
>> path , path_ind ,
>> message , message_ind,
>> filemode , filemode_ind ,
>> len , len_ind )
>> char *path;
>> char *message;
>> char *filemode;
>> int len;
>> OCIExtProcContext *context;
>> short path_ind;
>> short message_ind;
>> short filemode_ind;
>> short len_ind;
>> {
>I don't intend to jump on every little detail, but the above declaration
>will make many compilers complain...

complain but succeed :)

[Quoted] many compliers on the other hand (if portability is important) will not process [Quoted] the next one... (i myself prefer the type checking I get with the following prototype)...

>Modern c(++) requests a declaration as follows:
>long __declspec(dllexport)
>OutputString (
> OCIExtProcContext* context ,
> char* path,
> short path_ind,
> char* message,


>Furthermore, if the "path_ind", the "message_ind" etcetera are #defined as
>literals somewhere in a header file (I can't tell from the posting), it is
>slightly more efficient to use "int" everywhere (instead of short).

they are not. They are INDICATOR variables. if they are 0, the data contains valid stuff (path is NOT NULL and not truncated). If path_ind is -1/1, the path variable is NULL or truncated (not C null, but rather database NULL, the char * path will not be NULL it will be some unset value). Before you access path in your application, you must check this value.

[Quoted] In the case of in/out variables, path_ind would be a short *. It is recommended [Quoted] that you always just use short -- not int. Its a short we pass around and while [Quoted] it might get promoted to int on the stack, since we frequently pass pointers to [Quoted] it -- you should just keep it short.

>And I don't recall by it by heart, but if you're using M$, it is common to
>use macro's for linker directives, instead of the "__declspec(dllexport)",
>but that is -of course- a matter of (bad) taste (hence the nickname "Macro
>Foundation Classes...").

See for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
Thomas Kyte         
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation
Received on Thu Aug 12 1999 - 13:12:27 CEST

Original text of this message