Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Looking for examples that call C functions from PL/SQL!
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$1_at_inet16.us.oracle.com>...
>>
>> 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 :)
many compliers on the other hand (if portability is important) will not process 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,
[snip]
>
>
>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.
In the case of in/out variables, path_ind would be a short *. It is recommended that you always just use short -- not int. Its a short we pass around and while it might get promoted to int on the stack, since we frequently pass pointers to 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 http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Thu Aug 12 1999 - 06:12:27 CDT
![]() |
![]() |