?
Solved

Call a shared library with PL/SQL

Posted on 2009-07-09
3
Medium Priority
?
367 Views
Last Modified: 2013-12-07
Hi,
i have a provided shared library which i need to call from within an PL/SQL procedure.

i got the the following from the vendor:

int functionxy( int arg0, int arg1, time_t arg2, const char *arg3, size_t arg4, char *arg5 )

so i'm not sure how to create/define the procedure in oracle, i was thinking of something like this:

CREATE OR REPLACE FUNCTION myFunction
    (arg0 IN PLS_INTEGER,
     arg1 IN PLS_INTEGER,
     arg2 IN PLS_INTEGER,
     arg3 IN CHAR,
     arg5 IN OUT CHAR)
RETURN PLS_INTEGER AS LANGUAGE C
    NAME "functionxy"
    LIBRARY myLib
    PARAMETERS (
        arg0,
        arg1,
        arg2,
        arg3,
        arg3 LENGTH,
        arg5
    );        

does this look correct so far? i'm really unsure on how to use the time_t type...

any help is appreciated.

thanks
Lukas    
0
Comment
Question by:lukas_ch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 74

Accepted Solution

by:
sdstuber earned 750 total points
ID: 24813186
You'll need to check the specific implementation of time_t for your library.

In most c implementations time_t  is a int or  long int.  So pls_integer will correspond fine.

In your pl/sql code you will probably want to convert the integer value into a date.

you can do that with the following calculation...

 TO_DATE('1970-01-01', 'yyyy-mm-dd') + (your_time_t_value/ 86400)
0
 

Author Comment

by:lukas_ch
ID: 24858098
sorry, took a little longer to test, as i had to sort out some OS issues...

the function worked on the first try! also the remark about calculating time_t helped me :-)

thanks.
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 24859049
would else did you need for me to earn an A?

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question