开发者

Application ID from db2 8.1.5 on Z/OS

I have been searching how to get application Id from db2 8.1.5 on Z/OS(remote). I found this link: http://www.ibm.com/developerworks/data/library/techarticle/0302stolze/0302stolze.html

In this link, it is said that there is not built-in function(application_id) in db2 开发者_如何学Cprior to 8.2 to get application id. So, i tried the solution said in this link. But when trying SQL function in previous link to register the Java method, db2 warns me in this way:

DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL0104N An unexpected token "FENCED" was found following "". Expected tokens may include: "DETERMINISTIC, VARIANT". SQLSTATE=42601

The function i tried:

CREATE FUNCTION application_id() 
   RETURNS VARCHAR(128) 
   SPECIFIC applId  EXTERNAL NAME 'appl_id.getApplicationId' 
   NOT FENCED  LANGUAGE JAVA  PARAMETER STYLE DB2GENERAL 
 DETERMINISTIC 
   NO SQL  NO EXTERNAL ACTION  ALLOW PARALLEL  DBINFO 

Java Method:

import java.sql.*; 
import COM.ibm.db2.app.*; 

public class appl_id extends UDF 
{ 
    public void getApplicationId(String result) throws Exception 
    { 
       try { 
           // set the output parameter based on DBINFO 
           set(1, getDBapplid()); 
       } 
       catch (Exception e) { 
           setSQLstate("38XXX"); 
           if (e.getMessage().length() > 0) { 
              setSQLmessage("Exception '" + e.getMessage() + 
                           "' encountered."); 
               } 
           else { 
                setSQLmessage("Exception '" + e.toString() + 
                           "' encountered."); 
           } 
       } 
     } 
}

Please help me.


According to IBM's DB2 for z/OS version 8 documentation on CREATE FUNCTION, NOT FENCED is not supported. NOT FENCED is supported in the DB2 Universal Database version 8 as noted in it's CREATE FUNCTION documentation. Try changing NOT FENCED to FENCED.


SQL104N means your sql statement is incorrect.

For call external scalar function (I'm not sure about z/OS) in case of db2luw, you can use SQLJ.INSTALL_JAR as below

CALL SQLJ.INSTALL_JAR('file:///C:/whitegladiolus.jar','MYJARX')

and see also http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/ad/r0006425.htm

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜