Application ID from db2 8.1.5 on Z/OS

泪湿孤枕 提交于 2019-12-13 04:45:42

问题


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 prior 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

Thanks in advence


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/7714023/application-id-from-db2-8-1-5-on-z-os

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!