DB2 z / OS:使用SQLCODE = -104创建函数失败

时间:2011-01-27 10:26:23

标签: db2

下面的create function语句在DB2 LUW上运行正常,但在DB2 V9.1 for z / OS上失败。

CREATE FUNCTION  PLAT_FN_GASN  (
 OBJID CHARACTER(18) )
  RETURNS CHARACTER(18) 
  LANGUAGE SQL 
  READS SQL 
  DATA DETERMINISTIC 
  NO EXTERNAL ACTION 
  RETURN SELECT SRCOBJID
  FROM PLAT_V_RELATIONSHIPS AS R2
  WHERE RELTYPENAME = 'ApplyTaskRefOutputSpec' AND MODELNAME = 'MiningTask'
    AND TGTOBJID = (SELECT SRCOBJID
              FROM PLAT_V_RELATIONSHIPS AS R1
              WHERE RELTYPENAME = 'ApplyOutputHasContentItems' AND MODELNAME = 'MiningTask'
               AND TGTOBJID = OBJID)

错误信息是:

ILLEGAL SYMBOL "SRCOBJID". SOME SYMBOLS THAT MIGHT BE LEGAL ARE: SOURCE PARAMETER STOP INHERIT RETURNS CALLED ALLOW CONTAINS. SQLCODE=-104, SQLSTATE=42601, DRIVER=3.53.71

我无法弄清楚SQL语句有什么问题。有人能给我一些线索吗?

感谢。

1 个答案:

答案 0 :(得分:0)

我发现原因是DB2 for z / OS V9不支持SQL UDF的RETURN中的标量选择。虽然语法是正确的。 DB2 for z / OS V10应该支持这一点。

感谢。