Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2004
    Location
    Istanbul
    Posts
    17

    Exclamation Unanswered: Does Oracle 9.2.0 support external procedures written in C++ ?

    Does Oracle 9.2.0 support external dynamic libraries ( dll's or .so's ) that their source code is C++ ?
    If so how to compile and link them ?
    I can write C code compile and link them as dynamic libraries and access some functions within this library by use of PLSQL. My listener configurations works.
    But does Oracle 9.2.0 support the libraries of C++ ??? I am researching this topic far long enough and nothing written as an exact answer of this question ...

    Can we define C++ classes and its functions in PLSQL ? if so where can I get some REAL information.

    Please help.

    Onur

  2. #2
    Join Date
    Aug 2004
    Location
    Istanbul
    Posts
    17
    I really need an answer. If anyone knows something. Or never heard about such thing please do not hesitate to answer.

    Just type In something

  3. #3
    Join Date
    Nov 2002
    Location
    Desk, slightly south of keyboard
    Posts
    697
    Hi,

    AIUI, ExtProc supports any external library which conforms to the 'C' calling convention. That is to say, the lib could be written in any language which either uses that calling convention by default, or allows you to specify the calling convention to be used either on a per function basis, or within the entire .dll.

    For example, a .dll function written in pascal would need the 'cdecl' modifier included in the function declaration.

    Assuming you can do the same in C++ then there is no reason why you cannot call functions in a C++ dll.

    I would think it highly unlikely that you could access classes or objects in their C++ native form. Rather you would need accessor functions which conform to the C calling convention, but which can themselves access your C++ classes.

    Hth
    Bill
    Please don't email me directly with questions. I've probably just got home from the pub and cannot guarantee the sanity of my answers. In fact, I can't believe I actually made it home.

  4. #4
    Join Date
    Aug 2004
    Location
    Istanbul
    Posts
    17

    what the

    So is that mean that i need to rewrite the code according to C calling convention ? Or compile and link it using different parameters ? ( seriously )

    Or were you drunk while answering ? :P (just kidding ofcourse)

  5. #5
    Join Date
    Nov 2002
    Location
    Desk, slightly south of keyboard
    Posts
    697
    Hi Andurin,

    I've just had a look here http://msdn.microsoft.com/library/de...onventions.asp and it states that C++ uses the C calling convention by default, so you shouldn't have any trouble there.

    However, the Oracle 8 docs (sorry, no 9 here) suggest that it isn't default, and that a C++ routine would use an extern "C" statement to make it conform to C calling convention.

    This from the Oracle 8 docs

    While this service is designed for intercommunication between SQL, PL/SQL, C, and Java, it is accessible from any base language that can call these languages. For example, a routine can be written in a language other than Java or C and still be usable by SQL or PL/SQL, provided that is callable by C. Therefore, a C++ routine, would use a C++ extern "C" statement in that routine to make it callable by C.
    The docs go on to say...

    Specifies the Windows NT calling standard (C or Pascal) under which the external routine was compiled. (Under the Pascal Calling Standard, arguments are reversed on the stack, and the called function must pop the stack.) If you omit this subclause, then the calling standard defaults to C.
    So, they both seem to contradict each other, and Oracle contradicts itself. I would go with whatever your specific C++ implementation says in order to ensure C calling convention.

    There is a C example in the 8i docs which show it using the OCI libraries to access the members of an Oracle8 object, but I think you need the reverse - Oracle accessing members of a C++ object. I doubt this would be possible without accessor (wrapper) functions. You have to remember that the datatypes passed to and from Oracle are fairly simple types (int, char* etc).

    Hopefully the following pseudo code will help.....

    Code:
    type cpclass [some complex C++ class] 
       {
       int cpclassfunction();
       int cpclassvalue;
       };
    
    int OracleCallableAccessorFunction() _cdecl
       {
       cpobject = new cpclass;
       var1 = cpobject.cpclassfunction;
       var2 = cpobject.cpclassvalue;
       result = var1 * var2;
       free cpobject;
       return result;
       }
    The function OracleCallableAccessorFunction conforms to C convention, but internally it goes on to use C++ complex types.

    If that doesn't help, then maybe some further detail on exactly what you want to do and why? I'll do my best in between beers :-)

    Hth
    Bill
    Please don't email me directly with questions. I've probably just got home from the pub and cannot guarantee the sanity of my answers. In fact, I can't believe I actually made it home.

  6. #6
    Join Date
    Aug 2004
    Location
    Istanbul
    Posts
    17

    Thanks

    Thanks Bill.
    For taking some time to answer my question.
    Your answer is quite understandable and helpfull.
    If there was a "report Nice post" button on the forum I would likely click on it and announce your effort to the public

    My problems still exist however. I think they will... forever.
    May be "the one" which is problemmatic is only "me".

    But your answer is still the answer for my question. Thanks alot.

    Onur.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •