Category: Oracle
2016-08-20 05:24:52
Original Address: the Oracle dynamic call external C library functions Author: libydwei2007
As the project in order to shorten development time, to have developed a good call an external C program in Oracle.
Find some posts online, combined with the actual summary of this article. I hope to be helpful.
Reference article: http: //www.cnblogs.com/mathitlin99/archive/2013/09/05/3303717.html
first compile the external dynamic library <span "=" "> libDialPlan.so
listener.ora
After the modification restart the listener: lsnrctl stop; lsnrctl start
viewing monitor status, should appear the following monitor items: PLSExtProc <span "=" ">
Creating Oracle library objects
Create function
) online articles, as well as a parameter according to the parameter 1.
But after I joined this parameter has not compile. After removal does not affect the use of the function.
2) corresponds to the numbers and strings binary_integer, varchar2 type. Originally C into an array type parameter is required, but no real Oracle array, only through a string instead.
3) In the course of my testing, and occasionally need to reboot to normal function is called. You can use the process to look at.
Find some posts online, combined with the actual summary of this article. I hope to be helpful.
Reference article: http: //www.cnblogs.com/mathitlin99/archive/2013/09/05/3303717.html
first compile the external dynamic library <span "=" "> libDialPlan.so
Click ( here) folded or unfolded
- gcc -fPIC -c LibDialPlan.cpp
- gcc -shared -o libDialPlan.so LibDialPlan.o -lstdc++
Modify files and Oracle TNS Listener files.
I do not know the direct copy is available. If you have questions, please pay attention to both sides of the equal sign and parentheses space .
tnsnames.ora
Click ( here) folded or unfolded
- ORADB =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.69.166)(PORT = 1521))
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = oradb)
- )
- )
- EXTPROC_CONNECTION_DATA=
- (DESCRIPTION=
- (ADDRESS_LIST=
- (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
- )
- (CONNECT_DATA=
- (SID = PLSExtProc)
- (PRESENTATION = RO)
- )
- )
Click ( here) folded or unfolded
- LISTENER =
- (DESCRIPTION_LIST =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.69.166)(PORT = 1521))
- )
- )
- ADR_BASE_LISTENER = /home/oracle/db/app
- SID_LIST_LISTENER =
- (SID_LIST =
- (SID_DESC =
- (GLOBAL_DBNAME = oradb)
- (SID_NAME = oradb)
- )
- (SID_DESC=
- (SID_NAME = PLSExtProc)
- (ORACLE_HOME = /opt/local/oracle/app/product/11.2.0/dbhome_2)
- (ENVS = EXTPROC_DLLS=ANY)
- (PROGRAM = extproc)
- )
- )
After the modification restart the listener: lsnrctl stop; lsnrctl start
viewing monitor status, should appear the following monitor items: PLSExtProc <span "=" ">
Click ( here) folded or unfolded
- [root@localhost admin]# lsnrctl status
- LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 04-AUG-2016 19:33:50
- Copyright (c) 1991, 2009, Oracle. All rights reserved.
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
- STATUS of the LISTENER
- ------------------------
- Alias LISTENER
- Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
- Start Date 04-AUG-2016 16:23:54
- Uptime 0 days 3 hr. 9 min. 55 sec
- Trace Level off
- Security ON: Local OS Authentication
- SNMP OFF
- Listener Parameter File /opt/local/oracle/app/product/11.2.0/dbhome_2/network/admin/listener.ora
- Listener Log File /opt/local/oracle/app/product/11.2.0/dbhome_2/network/log/listener.log
- Listening Endpoints Summary...
- (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
- (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.69.166)(PORT=1521)))
- Services Summary...
- Service "PLSExtProc" has 1 instance(s).
- Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
- Service "oradb" has 1 instance(s).
- Instance "oradb", status UNKNOWN, has 1 handler(s) for this service...
- The command completed successfully
- [root@localhost admin]#
Click ( here) folded or unfolded
- create or replace library hytpdtbilldb.Fun_Ext_Proc
- as '/opt/local/Oracle_install/Oracle_Call_External_C/libDialPlan.so';
) online articles, as well as a parameter according to the parameter 1.
But after I joined this parameter has not compile. After removal does not affect the use of the function.
2) corresponds to the numbers and strings binary_integer, varchar2 type. Originally C into an array type parameter is required, but no real Oracle array, only through a string instead.
3) In the course of my testing, and occasionally need to reboot to normal function is called. You can use the process to look at.
Click ( here) folded or unfolded
- create or replace function hytpdtbilldb.Air2Gsi
- (x binary_integer,y varchar2)
- return varchar2
- as
- language C
- library hytpdtbilldb.Fun_Ext_Proc
- name "Air2Gsi";
- /