在结果集列中包含用户定义 Table 函数中返回的 5 个列

include in result set columns the 5 returned columns in a User Defined Table Function

我有一个 UDTF 总是 return 1 行 6 列 UDTF有一个参数

我想将 5 列包含在查询的结果集中。我正在查询的 table 有一列我想用作每行的参数

我一直没能找出正确的语法。

有什么建议吗?

UDTF

create function xxxx.UF_yyyyyy(USERID CHAR(10))
    returns table (
                p2User char(10),
                STATUS CHAR(3),
                USED DEC(7, 0),
                CREATED DEC(7, 0),
                SIGNON DEC(7, 0),
                EXCLUDE DEC(7, 0))
    language RPGLE
    NOT DETERMINISTIC
    NO SQL
    DISALLOW PARALLEL
    NOT FENCED
    EXTERNAL NAME 'xxxx/UF_yyyyyy'
    PARAMETER STYLE DB2SQL

示例

select * from table(xxxx/UF_yyyyyy(CHAR('CMFIRST   '))) a

结果

 P2USER     STATUS USED    CREATED SIGNON  EXCLUDE
 ---------- ------ ------- ------- ------- -------
 CMFIRST    ACT    1170926 1150826 1170926       0

这是一个 select 我试过的例子

SELECT T1.AQABVN, T1.AQA8TX, 
       (SELECT COUNT(*) FROM fffff T4 WHERE T4.BDABVN = T1.AQABVN) AS SACCMS,
        t2.p2User, t2.used
FROM  
    zzzzz T1 
    full join table(xxxx.UF_yyyyyy(T1.AQABVN)) t2 on T1.AQABVN = t2.p2User

结果

[SQL0205] Column P2USER not in table T2 in *N.

成功了

SELECT T1.AQABVN, T1.AQA8TX, 
       (SELECT COUNT(*) FROM fffff T4 WHERE T4.BDABVN = T1.AQABVN) AS SACCMS,
        t2.status, t2.used, t2.created, t2.signon, t2.exclude 
FROM  
  zzzzz T1 
    join 
  table(SMLFQA.UF_XAJKUPR(T1.AQABVN)) t2 on T1.AQABVN = t2.p2User