Solved

Call a shared library with PL/SQL

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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.
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 shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now