Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: oracle external library problem

Re: oracle external library problem

From: Christopher M. Day <christopher.day_at_rdbms.freeserve.co.uk>
Date: Wed, 17 Feb 1999 23:02:03 +0000
Message-ID: <36CB4A6B.8C965F75@rdbms.freeserve.co.uk>


Nivesh

You need to declare the purity of your function using

PRAGMA RESTRICT_REFERENCES (myfunc,WNDS,RNDS,WNPS,RNPS);

Chris.

nivesh.patnaik_at_trw.com wrote:
>
> I have been trying to make an external call to a C program from
> within a trigger, so I thought I would create a function that
> would call the c program. The simple program I am trying to run is:
>
> /* File: printhello.c */
>
> #include <stdio.h>
>
> int main (int argc, char *argv[])
> {
> FILE *fp;
>
> if ((fp = fopen("/tmp/hellofile.txt", "w")) == NULL) {
> exit (1);
> }
> else {
> if (argc == 2) {
> printf("Your argument was %s\n", argv[1]);
> }
> else {
> fprintf(fp, "Hello, and in case we don't meet again, goodbye!\n");
> fclose(fp);
> exit (0);
> }
> }
> }
>
> I created a shared library using:
> gcc -I$ORACLE_HOME/dbms/demo -I$ORACLE_HOME/rdbms/public
> -I$ORACLE_HOME/plsql/public -I$ORACLE_HOME/network/public -c printhello.c
>
> make -f demo_rdbms.mk extproc_callback SHARED_LIBNAME=my_lib.so
> OBJS=printhello.o
>
> All that I am trying to do is write to a file.
>
> I then created the Oracle library and defined my function:
>
> create library MY_LIB as 'my_lib.so';
>
> CREATE OR REPLACE FUNCTION myfunc
> (uname IN VARCHAR2)
> RETURN INTEGER
> AS EXTERNAL LIBRARY MY_LIB
> NAME printhello
> LANGUAGE c
> CALLING STANDARD c
> PARAMETERS (uname);
>
> I tried using the function, but it gives an error:
>
> SQL> select myfunc('WriteMe') from dual;
> select myfunc('WriteMe') from dual
> *
> ERROR at line 1:
> ORA-06571: Function MYFUNC does not guarantee not to update database
>
> I have checked with our DBA, and we have a listener dedicated to
> external procedure calls. What am I doing wrong?
>
> Nivesh
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Received on Wed Feb 17 1999 - 17:02:03 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US