Solved

Call a shared library with PL/SQL

Posted on 2009-07-09
3
360 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
  • 2
3 Comments
 
LVL 73

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 73

Expert Comment

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

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

809 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