Solved

Call a shared library with PL/SQL

Posted on 2009-07-09
3
365 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 250 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

730 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