I've implemented a function as C code for db2. The library name is called libmyfoo.so and is stored id /usr/local/lib as declared in the External declaration. When I try to execute this function I get this error back.

SQL0444N  Routine "*HOT_IMPL" (specific name "SQL131129160401700") is 
implemented with code in library or path 
"...local/lib/limyfoo.so", function "*" which cannot be 
accessed.  Reason code: "4".  SQLSTATE=42724

Essentially it is saying that it cannot reach that function but that's not true. I've also setup the LD_LIBRARY_PATH for the db2inst1 user pointing to that folder.

On top of that I've also called the following that shuld reinforce the research path.

db2set DB2LIBPATH='/usr/local/lib:/home/db2inst1/sqllib/lib64:
/home/db2inst1 /sqllib/lib32'

What can I look to solve this error? db2diag doesn't change when I call the function so it is not helpful. How at least to debug it?

I am running db2 V9.7 on Linux Centos 6.4.

Below pieces of SQL function and C function.

create or replace function MyFoo()
  returns  table(
    a   integer,
    b   double ,
  external name '/usr/local/lib/libmyfoo.so!MyFoo'
  language c
  parameter style sql
  no sql
  not fenced threadsafe
  returns null on null input
  not deterministic
  no external action
  no final call
  disallow parallel
  no dbinfo
  cardinality 1000

 #if defined (_MSC_VER)
 extern "C" __declspec(dllexport) void SQL_API_FN MyFoo(
 extern "C" void SQL_API_FN MyFoo(

     SQLUDF_DOUBLE  *b, 

     SQLUDF_CHAR    *, 
     SQLUDF_NULLIND *i_ix,
     SQLUDF_NULLIND *i_ixp
   // Grab the snapshot on the first call.

I have just increased the log error to 4 and this is what I have in the log (finally). It appears 3 times.

 2013-12-04- I29606333E883       LEVEL: Info
 PID     : 29170                TID  : 139915404764928PROC : db2sysc
 INSTANCE: db2inst1             NODE : 000          DB   : XTI
 APPHDL  : 0-7                  APPID: *LOCAL.db2inst1.131204171845
 EDUID   : 21                   EDUNAME: db2agent (XTI)
 FUNCTION: DB2 UDB, oper system services, sqlofica, probe:10
 DATA #1 : SQLCA, PD_DB2_TYPE_SQLCA, 136 bytes
  sqlcaid : SQLCA     sqlcabc: 136   sqlcode: -444   sqlerrml: 70
  sqlerrmc: *HOT_IMPL SQL131202104044600 ...local/lib/libmyfoo.so * 4
  sqlerrp : SQLERLIB
  sqlerrd : (1) 0x00000000      (2) 0x00000000      (3) 0x00000000
            (4) 0x00000000      (5) 0x00000000      (6) 0x00000000
  sqlwarn : (1)      (2)      (3)      (4)        (5)       (6)    
            (7)      (8)      (9)      (10)        (11)     
  sqlstate: 42724
  • 1
    What are the permissions on the file? Is it group/world readable/executable? – Philᵀᴹ Nov 29 '13 at 16:23
  • @Phil is /usr/local/lib it has "-rwxr-xr-x. 1 root root" like all other shared libraries. – Abruzzo Forte e Gentile Dec 2 '13 at 9:47
  • When I use this function is it logged somewhere? I cannot understand whether the function start executing and then stops for some missing access or if the entire library cannot be retrieved. – Abruzzo Forte e Gentile Dec 2 '13 at 10:23
  • Please provide the CREATE FUNCTION statement and (at least) the first couple of lines of the C function declaration in your code – Ian Bjorhovde Dec 3 '13 at 16:13
  • Hi Ian. Just done. The most frustrating thing is that I cannot debug it and in db2diag log there is no indication about it..no error message at all that might help me with that. – Abruzzo Forte e Gentile Dec 4 '13 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.