6 Replies Latest reply: Feb 5, 2013 4:50 AM by Gennady Sigalaev RSS

    Calling external C function from plsql - ORA-06521 error mapping function

    955945
      Dear All,

      I have the following C code:
      class Factorial {
        public:
        int getVal (int a);
      };
      
      #include "Factorial.h"
      int Factorial::getVal (int a){
        if(a!=1){
          return(a * getVal(a-1));
          }
        else return 1;
      }
      I created the shared library(.so), created library inside Oracle DB, set up the extproc in listener and etc.
      Also I created the following plsql code:
      CREATE OR REPLACE PACKAGE c_pack AS
        function factorial_func(x in pls_integer) return pls_integer;
      END;
      /
      CREATE OR REPLACE PACKAGE BODY c_pack AS
      
         function factorial_func(x in pls_integer)
           return  pls_integer
         as language c
         library sys.c_factorial
         name "getVal";
         
      END;
      /
      When I am trying to execute this function always get the ORA-06521. I changed the data types - but nothing changed.

      Please help.

      Just in case, listener.ora
      LISTENER =
        (DESCRIPTION_LIST =
          (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = db)(PORT = 1521))
                         (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) 
          )
        )
      
      ADR_BASE_LISTENER = /u01/app/oracle
      
      SID_LIST_LISTENER =
        (SID_LIST =
          (SID_DESC =
           (SID_NAME = PLSExtProc)
           (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
           (PROGRAM = extproc)
           (ENVS = "EXTPROC_DLLS=/u01/app/oracle/product/c_lib/factorial.so, LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/dbhome_1/lib")
          )
        )
      [oracle@db admin]$ lsnrctl status listener
      
      LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-FEB-2013 21:24:36
      
      Copyright (c) 1991, 2011, Oracle.  All rights reserved.
      
      Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db)(PORT=1521)))
      STATUS of the LISTENER
      ------------------------
      Alias                     listener
      Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
      Start Date                04-FEB-2013 21:23:37
      Uptime                    0 days 0 hr. 0 min. 58 sec
      Trace Level               off
      Security                  ON: Local OS Authentication
      SNMP                      OFF
      Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
      Listener Log File         /u01/app/oracle/diag/tnslsnr/db/listener/alert/log.xml
      Listening Endpoints Summary...
        (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db)(PORT=1521)))
        (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
      Services Summary...
      Service "PLSExtProc" has 1 instance(s).
        Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
      Service "orcl" has 1 instance(s).
        Instance "orcl", status READY, has 1 handler(s) for this service...
      Service "orclXDB" has 1 instance(s).
        Instance "orcl", status READY, has 1 handler(s) for this service...
      The command completed successfully
      [oracle@db admin]$