PL/SQL external procedure
Hello,
I added a new function to our external library. The new function used a other library ImageMagickWand.
When I call with pl/SQL an old function of the new library I get the follwing messages:
select sys_resource.get_grafikinfo('/obj-media/i33/vcm/i33vcm90901/flo.jpg','B') from dual
FEHLER in Zeile 1: (Error in line 1)
ORA-06520: PL/SQL: Fehler beim Laden der externen Library (PL/SQL Error loading external library)
ORA-06522: /dufhome/dba/oracle/product/rdbms/11202/lib/libduf.so: undefined
symbol: NewMagickWand
ORA-06512: in "SYS_RESOURCE.FILE_JPG", Zeile 1
ORA-06512: in "SYS_RESOURCE.GET_GRAFIKINFO", Zeile 109
Did I have to define the used library ImageMagickWand? How and where did I have to define them?
We used Oracle RDBMS 11.2.0.2 EE on Linux x86-64.
I hope, somebody can help.
Regards Heike
look at (Doc ID 851610.1)
Similar Messages
-
Database design and pl/sql vs external procedures
hi,
My project involves predicting arrival time of a bus at a bus-stop, given statistical data of traffic patterns on the previous n(say 3) days, as well as the current location of the bus(latitude-longitude).
Given current bus location, I derive my distance-until-destination bus-stop, which must be translated into time until arrival.
Ive enlisted the triggers and procedures involved in making the prediction. Thse procedures especially the determination of perpendicular distances involve some complex trigonometric operations. I would like to know if my approach is correct and my database design is suited for the operations to b performed.
Will it be more efficient to implement the procedures as external procedures or as pl/sql blocks
This is my database design:
LINKS ( a link is the road segment between adjacent bus-stops)
LINK_ID NUMBER [PRIMARY-KEY]
START_LATITUDE NUMBER
START_LONGITUDE NUMBER
START_STOP_ID NUMBER
END_LATITUDE NUMBER
END_LONGITUDE NUMBER
END_STOP_ID NUMBER
LINK_LENGTH NUMBER
BUS_ROUTE
ROUTE_ID NUMBER
LINKS_ENROUTE VARRAY(30) OF NUMBER
STOPS_ENROOUTE VARRAY(30) OF NUMBER
TRACK(keeps track of current location of bus)
BUS_ID NUMBER [PRIMARY-KEY]
ROUTE VARCHAR2(20)
LATITUDE NUMBER
LONGITUDE NUMBER
TS TIMESTAMP
LINK_ID NUMBER
START_STOP NUMBER
END_STOP NUMBER
ARRIVAL_TIMES(actual arrival times of the bus, updated by track)
BUS_ID NUMBER [PRIMARY-KEY]
BUS_ROUTE VARCHAR2(20)
ARRIVAL TIMESTAMP
STOP_ID NUMBER
ETA (expected time of arrival)
BUS_ID NUMBER
BUS_ROUTE VARCHAR2(20)
BUS_STOP_ID NUMBER
ARR_TIME VARRAY(5) OF TIMESTAMP
Triggers and procedures
1)TRACK_TRIGGER
On insert/update of track determine which link the us is currently on.
Invoke a procedure that calculates perpendicular distance from current location to all links en-route (cursor on LINKS).
Results are stored in a temporary table. Select the link-id of the tuple whose perpendicular distance is MINIMUM. This is the link the bus is currently on. Place link-id, start_stop_id and end_stop_id in corresponding row of TRACK.
2)ARRIVAL_TRIGGER
update ARRIVAL_TIMES.and store in ARRIVAL_TIMES that start-stop id with the time-stamp of the current track record.
b)update ETA: Find the BUS-STOPS that come before the START_STOP of current track record. All these rows are deleted from the ETA tables, as the bus has already crossed these stops.
3)Prediction Algorithm Procedure.
Determine distance until destination for each STOP, 20 stops down from stop current location.
Determine current avg. speed of the bus over a 2 hour window, by dividing total distance traveled by time taken.
Calculate time-until arrival T1=current avg. speed * distance until destination
From the records of previous n days (say n=3) find those buses on the same route that were near the link the bus is currently on. Again determine avg speed over 2 hour window and calculate avg. speed.
Calculate travel time T(i) = speed*distance until destination. i.=2,3, 4
The final predicted arrival time is a weighted sum of all T(i).
I hope Im not asking for too much, but the help would be greatly appreciated.
Thankyou,
Aminahello,
actually i can manage ETA without a varray, since there will b a maxximum of 3 -4 values of expected arrival times at each stop. this can b done with separate columns.
though i dont quite understand how lag() will help me...from what i understand lag() is to access values of previous rows. but in ETA table each element in the varray(if there is one) is going to be the expected arrival time of buses on a particular route at that particular stop, and is different from the arrival time at a previous stop(i.e.row).
but for my other table BUS_ROUTE i have 2 varrays describing the links and stops enroute. in quite a few procedures i have to loop through these arrays and perform some calculations in every iteration is varray the best way 2 go, or nested tables?
Thank you
Amina
As an aside, external procedures tend by their very
nature to be slow - there's an overhead incurred
each time we step outside the database. Therefore
you really ought to avoid using a C extproc unless
your calculations really cannot be done in PL/SQL or
a Java Stored Procedure.
Also, before you go down the VARRAY route you should
consider the virues of analytic functions, notably
[url=http://download-west.oracle.com/docs/cd/B1050
1_01/server.920/a96540/functions56a.htm#83619]LAG()[/u
rl]. I think you really ought to do some
benchmarking of parformance before you start afdding
denormalised columns like ETA. You may find the
overhead in maintaining those columns exceeds their
perceived benefits.
Cheers, APC -
Hi,
I'm new to SharePoint 2013 I want to be able to query a MSSQL database from a SharePoint App I have tried to create an External Content Type (ECT) which is produced from a MSSQL stored Procedure, this procedure has several parameters which are needed to
filter the data correctly. From here I want to produce an external list which I can then query from a c# SharePoint app. If I leave the filters in the ECT null then the list is of course empty or if enter a default values the results are limited
for the app to query so are no good.
I want to dynamically pass values to the ECT when querying from the app, is this not possible. Should I just be returning everything in an external list and then letting the query in the app filter the data, this seems inefficient?
Is this the best way to do this or should I be doing this differently?
Please can someone point me in the right direction.
ThanksHi Pandra801,
When you create a the external content type, please try to add a filter based on your select statement.
http://arsalkhatri.wordpress.com/2012/01/07/external-list-with-bcs-search-filters-finders/
Or, try to create a stored procedure based on your select statement, then create ECT using the SQL stored procedure.
A step by step guide in designing BCS entities by using a SQL stored procedure
http://blogs.msdn.com/b/sharepointdev/archive/2011/02/10/173-a-step-by-step-guide-in-designing-bcs-entities-by-using-a-sql-stored-procedure.aspx
I hope this helps.
Thanks,
Wendy
Wendy Li
TechNet Community Support -
We have an external procedure running fine on 8.1.7 on VMS. After compiling and linking succesfully under 10.1.0, I get ORA-06521 PL/SQL: Error mapping function and ORA-06522: ERROR - vms_dlsym for file x, where x in the filename of the linked executable. Another external procedure that does not connect to the 10.1.0 database runs fine. What could be causing this error in Server 10.1.0 on VMS?
Thanks,
DaveHere is the code to create the function:
CREATE OR REPLACE FUNCTION f1
(h_file_name IN VARCHAR2)
RETURN BINARY_INTEGER
IS EXTERNAL
LIBRARY l1
NAME "f1"
LANGUAGE C
WITH CONTEXT
PARAMETERS
(CONTEST,
h_file_name string);
Here is the beginning of the Pro*C:
int f1(epctx, h_file_name)
OCIExtProcContext *epctx;
char h_file_name[70];
char h_line_txt [251];
int lineno;
FILE *fptr;
/* register the connection context ... */
EXEC SQL REGISTER CONNECT USING :epctx;
The function loads a flat file into the database. It is probably not related but are unable to SQLPLUS/ or SQLLDR/ into the database from an OS autheniticated account (get ORA-12547: TNS:lost contact.) Thanks for taking the time to look at this. There aren't many people trying this on VMS, I'd bet. -
SQL Developer and External Procedures not in tree.
Does sql Dveloper add external procedures to the object browser tree? I have SQL Developer 1.5 and if you have external procedures/functions before your regular PLSQL objects they will not display in the tree. I can make the tree work but the tree still doesn't capture the externals. Am I doing something wrong or should this be a feature request?
VSAMPLE1 shows the problem.
VSAMPLE2 is a try to resolve...
/* the problem.. */
CREATE OR REPLACE package VSAMPLE_1 IS
PROCEDURE foobar(feedname IN VARCHAR2);
END VSAMPLE_1;
CREATE OR REPLACE PACKAGE BODY VSAMPLE_1
IS
* Function Name:- canread
* Description :-This function checks the file will give any error or not while reading
FUNCTION canread (FILE IN VARCHAR2)
RETURN NUMBER AS LANGUAGE JAVA NAME 'com.myCompany.myApp.bulk.FileUtil.canRead (java.lang.String) return int';
* Function Name:- is_exist
* Description :-This function checks the existance of the filein the required folder
FUNCTION is_exist (FILE IN VARCHAR2)
RETURN NUMBER AS LANGUAGE JAVA NAME 'com.myCompany.myApp.bulk.FileUtil.exists (java.lang.String) return int';
* Function Name:- isDirectory
* Description :-This function checks the name provided by the user is a directory or not
FUNCTION isDirectory (FILE IN VARCHAR2)
RETURN NUMBER AS LANGUAGE JAVA NAME 'com.myCompany.myApp.bulk.FileUtil.isDirectory (java.lang.String) return int';
* Function Name:- isFile
* Description :-This function checks the name provided by the user is a file or not
FUNCTION isFile (FILE IN VARCHAR2)
RETURN NUMBER AS LANGUAGE JAVA NAME 'com.myCompany.myApp.bulk.FileUtil.isFile (java.lang.String) return int';
* Function Name:- isExist
* Description :-This function checks the existance of file,correctness of the directory provided by the user.
* @Param file_name :- File Name in directory
* @return retcode :- Error checking while uploading the feed.
FUNCTION isExist(file_name IN VARCHAR2,
is_dir BOOLEAN)
RETURN PLS_INTEGER
IS
retcode PLS_INTEGER := -1;
v_errcode PLS_INTEGER;
v_errtext VARCHAR2(1000);
l_section_name VARCHAR2(32) := 'isExist ' ;
BEGIN
IF VTMLOG.isDebugEnabled THEN
VTMLOG.debug(l_section_name,$$PLSQL_LINE, 'Checking existense of '||file_name);
END IF;
retcode := is_exist(file_name);
IF retcode = 1 THEN
IF is_dir THEN
retcode := isDirectory(file_name);
ELSE
retcode := isFile(file_name);
END IF;
IF retcode = 1 THEN
retcode := canread(file_name);
IF retcode != 1 THEN
VTMLOG.error(l_section_name,$$PLSQL_LINE, ' Can not read ' || file_name);
END IF;
ELSE
VTMLOG.error(l_section_name,$$PLSQL_LINE, ' Unable to check if ' || file_name || ' is directory or file ');
END IF;
ELSE
VTMLOG.error(l_section_name,$$PLSQL_LINE, file_name || ' does not exist ');
END IF;
VTMLOG.debug(l_section_name,$$PLSQL_LINE, 'Leaving ' );
RETURN retcode;
EXCEPTION
WHEN OTHERS THEN
VTMLOG.SHOW_ERROR_MESSAGE(l_section_name,$$PLSQL_LINE);
RAISE;
END isExist;
PROCEDURE foobar(feedname VARCHAR2)
IS
retval PLS_INTEGER;
BEGIN
/* implementation omitted */
retval := isExist('feed.txt',false);
EXCEPTION
WHEN OTHERS THEN
RAISE;
END foobar;
END VSAMPLE_1;
/* This version at least shows the tree. But I can't reach the external by clicking in the navigation tree just the placeholders */
PROCEDURE foobar(feedname IN VARCHAR2);
END VSAMPLE_2;
CREATE OR REPLACE PACKAGE BODY VSAMPLE_2
IS
FUNCTION canread (FILE IN VARCHAR2) RETURN NUMBER;
FUNCTION is_exist (FILE IN VARCHAR2) RETURN NUMBER;
FUNCTION isDirectory (FILE IN VARCHAR2) RETURN NUMBER;
FUNCTION isFile (FILE IN VARCHAR2) RETURN NUMBER;
* Function Name:- isExist
* Description :-This function checks the existance of file,correctness of the directory provided by the user.
* @Param file_name :- File Name in directory
* @return retcode :- Error checking while uploading the feed.
FUNCTION isExist(file_name IN VARCHAR2,
is_dir BOOLEAN)
RETURN PLS_INTEGER
IS
retcode PLS_INTEGER := -1;
v_errcode PLS_INTEGER;
v_errtext VARCHAR2(1000);
l_section_name VARCHAR2(32) := 'isExist ' ;
BEGIN
IF VTMLOG.isDebugEnabled THEN
VTMLOG.debug(l_section_name,$$PLSQL_LINE, 'Checking existense of '||file_name);
END IF;
retcode := is_exist(file_name);
IF retcode = 1 THEN
IF is_dir THEN
retcode := isDirectory(file_name);
ELSE
retcode := isFile(file_name);
END IF;
IF retcode = 1 THEN
retcode := canread(file_name);
IF retcode != 1 THEN
VTMLOG.error(l_section_name,$$PLSQL_LINE, ' Can not read ' || file_name);
END IF;
ELSE
VTMLOG.error(l_section_name,$$PLSQL_LINE, ' Unable to check if ' || file_name || ' is directory or file ');
END IF;
ELSE
VTMLOG.error(l_section_name,$$PLSQL_LINE, file_name || ' does not exist ');
END IF;
VTMLOG.debug(l_section_name,$$PLSQL_LINE, 'Leaving ' );
RETURN retcode;
EXCEPTION
WHEN OTHERS THEN
VTMLOG.SHOW_ERROR_MESSAGE(l_section_name,$$PLSQL_LINE);
RAISE;
END isExist;
PROCEDURE foobar(feedname VARCHAR2)
IS
retval PLS_INTEGER;
BEGIN
/* implementation omitted */
retval := isExist('feed.txt',false);
EXCEPTION
WHEN OTHERS THEN
RAISE;
END foobar;
* Function Name:- canread
* Description :-This function checks the file will give any error or not while reading
FUNCTION canread (FILE IN VARCHAR2)
RETURN NUMBER AS LANGUAGE JAVA NAME 'com.myCompany.myApp.bulk.FileUtil.canRead (java.lang.String) return int';
* Function Name:- is_exist
* Description :-This function checks the existance of the filein the required folder
FUNCTION is_exist (FILE IN VARCHAR2)
RETURN NUMBER AS LANGUAGE JAVA NAME 'com.myCompany.myApp.bulk.FileUtil.exists (java.lang.String) return int';
* Function Name:- isDirectory
* Description :-This function checks the name provided by the user is a directory or not
FUNCTION isDirectory (FILE IN VARCHAR2)
RETURN NUMBER AS LANGUAGE JAVA NAME 'com.myCompany.myApp.bulk.FileUtil.isDirectory (java.lang.String) return int';
* Function Name:- isFile
* Description :-This function checks the name provided by the user is a file or not
FUNCTION isFile (FILE IN VARCHAR2)
RETURN NUMBER AS LANGUAGE JAVA NAME 'com.myCompany.myApp.bulk.FileUtil.isFile (java.lang.String) return int';
END VSAMPLE_2;
/Hi,
I am afraid that according to the error message, it seems that this issue is mainly related to third-party, since issues using oracle database are not supported here, you could consider posting this issue in its website to get supports.
In addition, you could mark any reply as answer if it is helpful.
Thanks for your understanding.
Regards.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
External procedure with Pro*C in it
I have some C functions that I have compiled into a shared library on Unix.
One of the functions contains a SQL statement to insert into a table, so I
compile the file with Pro*C. It compiles fine. I have another C program
that calls the function within my shared library. It runs fine and the shared
library does insert the data into the table.
I create an Oracle library that points to the shared library, then create a stored
function in the database that executes the routine in the shared library. At
this point, everything seems in place. We have been using external procedures
for a while, and they seem to work OK. This is the first one we have, though that
has Pro*C code in it.
When I execute the stored function to execute my Pro*C routine, I get the errors
ORA-06520: PL/SQL: Error loading external library
ORA-06522: Unresolved external.
This shared library is the first one that we are using that has Pro*C in it. The
documentation doesn't say anything about being able to use Pro*C routines
as external procedures; but it doesn't say you can't. Am I attempting the impossible?
If not, what am I missing?
nullIs your library object pointing to one shared library and in turn function in this library is 'looking' to another shared library? if so, that is not allowed
-
Problem in Calling External Procedure
Hello,
I am trying to call external procedure written in C from PL/SQL.
Here are the codes :
For external procedure:
#include<stdio.h>
void extproc_fn ( void )
FILE * file_handle;
if (( file_handle = fopen ( "/root/cprogs/extproc.out", "a" )) != NULL )
fwrite ( "External Procedure Testing", 26, 1, file_handle );
fclose ( file_handle );
I have created library as :
create or replace library extproc_lib as '/root/cprogs/extproc.so';
And the procedure :
create or replace procedure extproc_proc as
external
name "extproc_fn"
library extproc_lib
language c;
My listener and tnsname is configured correctly.
But when I try to connect to Oracle by that tnsname, extproc program core dumps under $ORACLE_HOME/network/log directory. Under WinNT, it creates a Dr. Watson error.
Any idea what might have gone wrong.
Thanks in advance.
Soumen Ghoshhi there,
everything u did is correct as far as i recollect about external procedures ,the only thing that i suppose is missing is that u forgot to grant permissions on the library to the user...pls check this once i hope this works...
bye
Atul -
Cannot get external procedural call in Oracle RAC Environment
Cannot get external procedure call to work in our test RAC env.
We are able to get it to work in our DEV env which is a single instance
LISTENER.ORA:
NODE1:
# listener.ora Network Configuration File: /opt/oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER_SBLBGT01 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = sblbgt01-vip1)(PORT = 1521)(IP = FIRST))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.41.1.21)(PORT = 1521)(IP = FIRST))
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /opt/oracle/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
(ENVS="EXTPROC_DLLS=ANY")
NODE2:
# listener.ora.sblbgt02 Network Configuration File: /opt/oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora.sblbgt02
# Generated by Oracle configuration tools.
LISTENER_SBLBGT02 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = sblbgt02-vip2)(PORT = 1521)(IP = FIRST))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.41.1.22)(PORT = 1521)(IP = FIRST))
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /opt/oracle/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
(ENVS="EXTPROC_DLLS=ANY")
2) ### If you are receiving errors, please list exact error messages and text: ###
(cont 1.)
tnsnames.ora (on both nodes):
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = extproc))
(CONNECT_DATA = (SID = PLSExtProc) (PRESENTATION = RO)))
[opt/oracle/app/oracle/product/10.2.0/db_1/network/admin]> tnsping EXTPROC_CONNECTION_DATA
TNS Ping Utility for Solaris: Version 10.2.0.3.0 - Production on 11-APR-2011 10:52:49
Copyright (c) 1997, 2006, Oracle. All rights reserved.
Used parameter files:
/opt/oracle/app/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = extproc)) (CONNECT_DATA = (SID = PLSExtProc) (PRESENTATION = RO)))
OK (0 msec)
Calling External Procedure:
SQL> execute ttran.shell('ls');
BEGIN ttran.shell('ls'); END;
ERROR at line 1:
ORA-28575: unable to open RPC connection to external procedure agent
ORA-06512: at "TTRAN.SHELL", line 1
ORA-06512: at line 1Any Reply Please...
would appreciate your help... -
Using an AIX archive file as a library for an external procedure.
I cannot use an archive file, created with the ar command, that contains a shared object that was created with the xlc and ld commands as a library for external procedures. I can use the shared object file created with the ld command as a library for an external procedure. Why would I encounter an invalid magic number and what is the resolution?
Example:
oracle:@husk21:/home/oracle> ksh -x ./Oracle_demo.ksh
+ rm shell.o shell.so shell.so.exp shell.so.imp
+ make -f /u01/oracle/product/11.1.0.7/db/rdbms/demo/demo_rdbms32.mk extproc_no_context SHARED_LIBNAME=shell.so OBJS=shell.o
/u01/oracle/product/11.1.0.7/db/bin/oraxlc -q32 -c -I/u01/oracle/product/11.1.0.7/db/rdbms/demo -I/u01/oracle/product/11.1.0.7/db/rdbms/public -I/u01/oracle/product/11.1.0.7/db/plsql/public -I/u01/oracle/product/11.1.0.7/db/network/public -I/u01/oracle/product/11.1.0.7/db/precomp/public shell.c
generate_export_list() { /bin/nm -X32_64 -B -h -g "$1" | grep -v ' U ' | awk '{print $3}' | egrep -v '^\.|^TOC' | sort | uniq ; }; generate_import_list() { LIB_NAME=$1; IMP_FILE=$2; cat /u01/oracle/product/11.1.0.7/db/rdbms/lib/xa.imp | head -1 | awk '{print $0, "." }' > ${IMP_FILE}; /bin/nm -X32_64 -C -B -h -g ${LIB_NAME} | grep ' U ' | grep -v "::" | grep -v "(" | grep -v "\.cc" | awk '{print $3}' | sed -e "s/\.//g" | grep -v "^_" >> ${IMP_FILE}; }; generate_import_list shell.o shell.so.imp; generate_export_list shell.o > shell.so.exp; /bin/ld -b32 -bnoentry -bM:SRE -bE:shell.so.exp -bI:shell.so.imp -o shell.so shell.o -L/u01/oracle/product/11.1.0.7/db/lib -lc_r -lm
ld: 0711-224 WARNING: Duplicate symbol: .system
ld: 0711-224 WARNING: Duplicate symbol: system
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
oracle:@husk21:/home/oracle> ar rv libshell.a shell.so
ar: Creating an archive file libshell.a.
a - shell.so
oracle:@husk21:/home/oracle> ar tv libshell.a
rwxr-xr-x 3514/3516 1263 Sep 08 10:00 2009 shell.so
oracle:@husk21:/home/oracle> file shell.so
shell.so: executable (RISC System/6000) or object module not stripped
oracle:@husk21:/home/oracle> file libshell.a
libshell.a: archive (big format)
SQL> CREATE OR REPLACE LIBRARY shell_lib is '/home/oracle/libshell.a';
/ 2
Library created.
SQL> CREATE OR REPLACE PROCEDURE shell(command IN char)
AS EXTERNAL
NAME "shell"
LIBRARY shell_lib
LANGUAGE C
PARAMETERS (command string);
/ 2 3 4 5 6 7
Procedure created.
SQL> exec shell('ls');
BEGIN shell('ls'); END;
ERROR at line 1:
ORA-06520: PL/SQL: Error loading external library
ORA-06522: 0509-022 Cannot load module /home/oracle/libshell.a.
0509-103 The module has an invalid magic number.
ORA-06512: at "V500.SHELL", line 1
ORA-06512: at line 1
SQL> CREATE OR REPLACE LIBRARY shell_lib is '/home/oracle/shell.so';
2 /
Library created.
SQL> exec shell('ls');
PL/SQL procedure successfully completedUsing an AIX archive file as a library for an external procedure.
-
External Procedure call from Trigger
I'd like to call an external C Procedure from
an Oracle Trigger.
In trying to get an example to work, after setting up the listener and tnsnames.ora for external procedures, the following SQL*Plus command behaves strangely:
CREATE LIBRARY TTest as "c:\winnt\system32\TTrigger.dll";
After entering this, the command line prompts for more data as if the command was not terminated. Tried single quotes, double quotes, forward slash, backward slash...
What is wrong with this command?
Thankshi,
COuld you send me the configuration parameters for listner and TNSNAMES? I am working so hard to set it up but getting stuck and I am sure that I am missing some configuration set up.
Please could you mail your tnsname a nd listner files to bellow shown address?
[email protected] ?
Thanks in advance
Suresh -
Error using EXTERNAL PROCEDURES on UNIX
I'm having troubles to run external procedures on UNIX. I'm following the extern.c example that comes by default. It works very well on my NT enviornment, but not on Unix.
I compiled the share library on my solaris OS, and then I create the library, procedures,etc.
But when I try to run the procedure I received the following error:
ERROR at line 1:
ORA-06520: PL/SQL: Error loading external library
ORA-06522: ld.so.1: extprocextproc: fatal: libucb.so.1: open failed: No such
file or directory
ORA-06512: at "SAMPLE.PLS_MAX", line 0
ORA-06512: at "SAMPLE.USEIT", line 8
ORA-06512: at line 1I'm having troubles to run external procedures on UNIX. I'm following the libtest1.c example that comes by default. It works very well on my NT enviornment, but not on Unix.
I compiled the share library on my solaris OS, and then I create the library, procedures,etc.
But when I try to run the procedure I received the following error:
ERROR at line 1:
ORA-06520: PL/SQL: Error loading external library
ORA-06522: Unresolved external
ORA-06512: at "YDBROW.ORA_TEST", line 0
ORA-06512: at line 8 -
Error mapping function in external procedure call
I'm trying to create an external procedure in PL/SQL8.1 to run an operating system command from within a PL/SQL block.
The C function couldn't be simpler:
extern void host_command(char *command)
(void)system(command);
It's even ignoring the return value of SYSTEM!
I've generated what I THINK is a shared object file and copied it to $ORACLE_HOME/lib/host_command.so
I've then done CREATE LIBRARY HOST_COMMAND_LIB as '...'
Then I created a PL/SQL procedure:
CREATE PROCEDURE SHELL(IP_COMMAND IN VARCHAR2)
AS
LANGUAGE C
NAME "host_command"
LIBRARY HOST_COMMAND_LIB
PARAMETERS (IP_COMMAND);
And then EXEC SHELL ('touch /tmp/fred')
That's when ORA-6521 is raised.
I am running Oracle8.1.7.4.0 on AIX 4.3
Am I missing something?
Any suggestions will be thankfully received.
Andrew HunterThanks.
In fact, using the supplied makefile in $ORACLE_HOME/plsql/demo and MAKING SURE THAT THE .SO IS EXECUTABLE(!) works. -
'Error mapping function' with external procedures
I'm trying to create an external procedure in PL/SQL8.1 to run an operating system command from within a PL/SQL block.
The C function couldn't be simpler:
extern void host_command(char *command)
(void)system(command);
It's even ignoring the return value of SYSTEM!
I've generated what I THINK is a shared object file and copied it to $ORACLE_HOME/lib/host_command.so
I've then done CREATE LIBRARY HOST_COMMAND_LIB as '...'
Then I created a PL/SQL procedure:
CREATE PROCEDURE SHELL(IP_COMMAND IN VARCHAR2)
AS
LANGUAGE C
NAME "host_command"
LIBRARY HOST_COMMAND_LIB
PARAMETERS (IP_COMMAND);
And then EXEC SHELL ('touch /tmp/fred')
That's when ORA-6521 is raised.
I am running Oracle8.1.7.4.0 on AIX 4.3
Am I missing something?
Any suggestions will be thankfully received.
Andrew HunterThanks.
In fact, using the supplied makefile in $ORACLE_HOME/plsql/demo and MAKING SURE THAT THE .SO IS EXECUTABLE(!) works. -
ORA-06520 when External Procedure run.
I need to run a C application that will run an external procedure and I am getting the following errors reported when I run the function call in PL/SQL.
The test program follows
declare
rn number;
begin
rn:=wpleca('CUSTCODE PASSTEST');
END;
The error that is generated is
ERROR at line 1:
ORA-06520: PL/SQL: Error loading external library
ORA-06522: ld.so.1: extproc: fatal: libgcc_s.so.1: open failed: No such file or directory
ORA-06512: at "CUSTOM.WPLECA", line 0
ORA-06512: at line 4
The C program follows
#include<stdio.h>
#include<stdlib.h>
int sysrun(char *command) {
int num;
char str[80];
strcpy (str, "/xxxx/test/adhoc/syscr/wpleca2unix.sh ");
strcpy (str,command);
num = system(str);
return num;
The C compile commands follow
gcc -fPIC -c wpleca.c
gcc -shared -o libwpleca.so wpleca.o
The create library command follows
CREATE OR REPLACE LIBRARY PLECA_LIB
AS '/xxxx/test/adhoc/syscr/libwpleca.so'
The create function call follows
CREATE OR REPLACE FUNCTION wpleca (params_in in varchar2)
return binary_integer
as language C
name "sysrun"
library pleca_lib
parameters(params_in string);
The shared library and the script both exist with approporate permissions
-rwxr-xr-x 1 root other 5800 Feb 27 14:12 /xxxx/test/adhoc/syscr/libwpleca.so
-rwxrwxr-x 1 xyz test 1139 Feb 27 14:14 /xxxx/test/adhoc/syscr/wpleca2unix.sh
Any help with this error would be most appreciated.We are getting the error, Has anyone faced this issue, appreciate your help in advance.
ERROR at line 1:
ORA-06520: PL/SQL: Error loading external library
ORA-06522: ld.so.1: extproc: fatal: /tmp/utils.so: wrong ELF class: ELFCLASS32
while trying to call the external C program
Steps done for calling external procedure
1. Insert entries in the tnsnames.ora and listner.ora at oracle server location
Tnsnames.ora
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC) (KEY = extproc_key))
(CONNECT_DATA = (SID = extproc))
Listner.ora
CALLOUT_LISTENER =
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = IPC)
(KEY = extproc_key)
SID_LIST_CALLOUT_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = extproc)
(ORACLE_HOME = /opt/oradba92/OraHome)
(PROGRAM = extproc)
(ENVS="EXTPROC_DLLS=ANY")
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ctsinpunsun10)(PORT = 1523))
2. restart the listener external service
3. create library using create library c_utils as ‘/tmp/c_utils.so’
4. create sample c program on /tmp location as test.c
5. compile c program on unix using cc test.c command
For compile c program
$ cc –c util.c command
Create object file
$cc –G –c util.c
Create .so file
$ld –r –o utils.so util.o
6. create object file of above c program using cc –G –c test.c , this command will create new object file as test.o
7. after creating the object file , create dynamic link using
ld –r –o utils.so test.o
8. Give the permission to utils.so as 775
Add “/tmp” path in LD_LIBRARY_PATH
9. using sqlplus execute the command “SELECT Plscallscdivisor_Func FROM dual” it will gives error as
ERROR at line 1:
ORA-06520: PL/SQL: Error loading external library
ORA-06522: ld.so.1: extproc: fatal: /tmp/utils.so: wrong ELF class: ELFCLASS32
Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
Message was edited by:
user573236 -
Problem with external procedure
Please,
i'm doing some experiments in Microsoft Win2003 environment calling a c function as external procedures.
I've build a sample using Dev-C++ that make a DLL (i don't know c language) named sysDLL.dll
DllClass::DllClass(char *cmd)
int num;
num = system(cmd);
I need only to execute some OS command from PL/SQL (rdbms 10.2).
I've putted DLL in $ORACLE_HOME\bin.
Then I've created library with this statement :
Create Library scott.c_sysdll as 'C:\oracle\product\10.2.0\db_3\bin\sysdll.dll'
and at the end I've created the procedure :
create or replace procedure scott.shell(cmd IN varchar2)
as language C
library c_SysDll
name "DllClass"
parameters (cmd string);
But when I execute this procedure from sql*plus I've always get :
ORA-06521: PL/SQL: Error mapping function
ORA-06522: Unable to load symbol from DLL
ORA-06512: at "SCOTT.SHELL", line 1
ORA-06512: at line 1
Please help me, thanks !Suggest that you first make it much simpler. Do not object orientation. Use plain vanilla flavour C. And even before using C, use a kernel call instead. For example, the gethostname() is a standard Socket call that you will find on many operating system (including Windows & Unix).
The following code sample illustrates (can be run as is via SQL*Plus):<font color="blue">
-- specify the external library (shared lib on Unix, DLL on Windows)
create or replace library libc as 'libc.sl';
-- The kernel call that we're going to wrap with a PL/SQL function:
-- int gethostname(char *hostname, size_t size);
-- wrapping this API call with a PL/SQL function
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
-- calling the kernel API routine from within PL/SQL
set serveroutput on
declare
host$ varchar2(60);
rc$ integer;
begin
rc$ := gethostname( host$, 60 );
dbms_output.put_line( 'hostname is ['|| host$ ||'] return code=['|| TO_CHAR(rc$) || ']' );
end;
/</font>
<p>
Of course, the DLL name for Window is different than the Shared Library ('libc.sl') used in the above snippet. Do not have a Win32 Oracle platform to test on, but you should find this API call in the winsock.dll library.
<p>
As for writing your custom extproc in C. Plain vanilla C is something as follows:
int dosomestuff()
return( 123456 );
<p>
Remember that this function has to be exported in the DLL interface.
<p>
Also keep in mind that using extproc is usually the last option to pursue when dealing with Oracle development. The basic rules are as follows:
1. Do it in SQL.
2. If it cannot be done in SQL, do it as a PL/SQL proc
3. If if cannot be done in PL/SQL. do it as a Java stored proc
4. If if cannot be done in Java, do is as an external proc<p>
The times that I need to resort to using Java is less than a handful (most obvious one is using Java to gain o/s command line access). I have never put external proc code into production as we have yet to have a need for something so exceptional, that it cannot be done using SQL, PL/SQL or Java as the last resort.
Maybe you are looking for
-
VAT declaration in Spain according RD 1065/2007
Spanish authorities require the declaration of VAT ledgers according Real Decreto RD 1065/2007. It implies to send to the authorities the detail of all invoices which are VAT relevant in a specific format. Does anybody know if SAP is going to cover t
-
How to round value of container element in task description
I am trying to round the value of the container element from 3 decimals to 2 decimals for display purposes. The command symbol in the task description is &_WI_Object_Id.OverallTotalCost&. I have looked at SAP Help and I have tried the suggestion of &
-
Speaker trouble with Satellite L750
Hello! I've been having some issues with my internal speakers on my Toshiba L750 Satellite laptop. I just got the laptop a couple months ago and so far, everything seems to be ok.... except for the speakers. So if I leave the laptop and put it on "sl
-
Can you attach a game system to a macbook?
I'm trying to figure out if there is some kind of adapter for any game system so that one is able to hook up the game system to a macbook. Thanks!
-
hi all i have two servers right now we've upgrade the apex in one of the server to 3.1.0.00.32 from 1.6.1.00.03 and the other is still in the old version 1.6.1.00.03 i want to ask if there is any important changes between the versions and if can be a