This discussion is archived
3 Replies Latest reply: Jan 3, 2008 11:51 PM by BillyVerreynne RSS

Is it possible to call a activeX control from PL/SQL...?

user546710 Newbie
Currently Being Moderated
Hi all,

Is it possible to call a activeX control from PL/SQL...? If yes, please give me sample code or any link.

Thanks,
Pal
  • 1. Re: Is it possible to call a activeX control from PL/SQL...?
    BillyVerreynne Oracle ACE
    Currently Being Moderated
    You cannot instantiate and call COM objects from PL/SQL. The language itself does not support that.

    You can however make external library (DLL) calls. Here's sample code from HP-UX. The approach on Windows will be exactly the same.

    -- we want to call the gethostname() API call
    -- int gethostname(char *hostname, size_t size);

    -- this call resides in the libc shared object (DLL in Unix speak)
    -- (for windows, this could have been kernel32.dll or an activeX dll)
    create or replace library libc as 'libc.2';
    /


    -- we create a wrapper for our API call in PL/SQL:
    create or replace function gethostname( hostname OUT string, size_t binary_integer ) return binary_integer is
    EXTERNAL
    LIBRARY libc
    NAME "gethostname"
    LANGUAGE C
    CALLING STANDARD C
    PARAMETERS (
    hostname STRING,
    size_t INT
    );
    /
    show errors


    -- then we test it
    set serveroutput on
    declare
    c varchar2(60);
    l integer;
    i integer;
    begin
    l := 60;
    i := gethostname( c, l );
    dbms_output.put_line( 'hostname ['|| c ||'] rc='|| TO_CHAR(i) );
    end;
    /

  • 2. Re: Is it possible to call a activeX control from PL/SQL...?
    user546710 Newbie
    Currently Being Moderated
    Hi..

    Thanks for your prompt reply. I created the function (gethostname) successfully as you said, but when i called this function, it is giving error like this. I am using

    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE     10.2.0.1.0     Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production

    ****************************************************************
    ORA-28595: Extproc agent : Invalid DLL Path
    *****************************************************************
    Any help is appreciated.
    Thanks,
    Pal
  • 3. Re: Is it possible to call a activeX control from PL/SQL...?
    BillyVerreynne Oracle ACE
    Currently Being Moderated
    The LoadLibrary() Win32 call is used to find the physical DLL and load it into memory. This API call first look in the current directory for the file, and then uses the PATH environmental variable to try and find the file.

    Thus you need to make sure PATH is properly set. A Win32 process runs in a 32bit VM (Virtual Machine). Been a very long time since I did Windows server side development, but as I recall this VM inherits the default o/s environment (unlike Unix where the parent process environment is inherited).

    You can set the environment using the Properties menu of the System desktop icon (or via Control Panel).

    However.. Oracle does not run as your user. Typically it is installed as the o/s user Oracle and this user owns all the Oracle processes (listener, instance, etc).

    So you will need to make sure that this user's environment is correctly configured... Further more than this, I'm out of my depth. Did a lot of Windows stuff back in the 90's, but for many years now I'm only using Unix/Linux professionally - with Windows being my console platform for playing games at home. :-)

    On the Linux/Unix side, I configure the environment variable via the Listener. E.g. Under the entry SID_LIST_LISTENER, I configure the external procedure handler as follows:

    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME=/tjs-dev/app/oracle/product/10.2.0)
    (PROGRAM = extproc)
    (ENVS = "EXTPROC_DLLS=ANY")
    )
    No idea how this applies and works on the Windows side.