How Does Oracle call Windows dynamic link library?

Source: Internet
Author: User
Oracle calls Windows dynamic link library.
Call a function in the dynamic link library.

Oracle creates an alias function or stored procedure (hereinafter referred to as a subroutine) to call a dynamic link library.
This function or stored procedure defines the ing relationship with external functions, including
1. Return Value
2. Parameter ing
3. External function name
4. Dynamic Link Library file of the external Function
This is similar to calling Windows dynamic link library in C.
The specific steps are as follows:
1. Create an Oracle Library
Create Library LIBTESTPROC as 'C: \ UserData \ xuxia \ TestProc \ Debug \ TestProc. dll'
2. Grant the specific user using this Library the execution permission
Grant Execute LIBTESTPROC to [UserName]
3. Define Oracle subprograms
Create or replace Function fnTestProc
Return Binary_Integer
As Language C
Library LibTestProc
Name "fnTestProc ";

If you think this is a good definition, it would be a big mistake.
Oracle has made this function a little complicated. Why isn't it as simple as defining extended stored procedures in ms SQL?
Oracle is a drag. To complete this task, you must call the Windows dynamic link library mechanism for Orcale.
As follows:

1. The client executes a Pl/SQL program.
2. Server Process found a subroutine for calling external functions
3. Server Process sends the request to the Oracle listener
4. The Oracle listener starts extproc. The process will not be aborted until the session ends.
5. extproc load the dynamic link library
6. extproc find matching function execution
7. extproc sends the execution result to Server Process

From the above mechanism, you will know that the Extproc process is essential. However, not all Oracle listeners have configured ExtProc,
Refer to the following article

Http://download.oracle.com/docs/cd/B10501_01/network.920/a96580/advcfg.htm#483609

If ExtProc is not configured for your listener,
Will happen
ORA-28575 unable to open RPC connection to external procedure agent

However, this is not required only when the listener is set.
You must add a special Oracle LocalName to the TNSNames. ora file on the Oracle server (not on other machines:

EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC ))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)

The ORA-28575 unable to open RPC connection to external procedure agent error will not continue until this occurs

It seems that everything is okay, but there are even more terrible errors waiting for you?

ORA-28576 lost RPC connection to external procedure agent
This error is confusing. The explanation on the official Oracle website is also vague.

Cause: A fatal error occurred in either an RPC network connection,
External procedure agent, or the invoked 3GL after communication had
Been established successfully.

Action: First check the 3GL code you are invoking; the most likely
Cause of this error is abnormal termination of the invoked "C" routine.
If this is not the case, check for network problems. Correct
Problem if you find it. If all components appear to be normal but
Problem persists, the problem cocould be an internal logic error in
RPC transfer code. Contact Oracle Support Services.

It seems that some problems with the external link library may also lead to such errors.

Later I learned that Oracle has two ways to call external programs: Standard C call and Pascal call. The default value is standard C call. stdcall is not supported.
The Pascal call method is no longer supported in VC. So if your program is developed with VC, the only way is
Modify the source code of your dynamic link library to the Standard C call and recompile
Example:
TESTPROC_API int fnTestProc (void); ==>
Extern "C"
{
TESTPROC_API int fnTestProc (void );
}

What if you want to call a dynamic link library without source code? Because most dynamic link libraries in Windows are defined as stdcall
You can create only one dynamic link library project by yourself, and then encapsulate dynamic link library functions without source code.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.