0

我有一个 UDTF 将始终返回 1 行 6 列 UDTF 有一个参数

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

我一直无法弄清楚正确的语法。

有什么建议么?

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 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.
4

1 回答 1

1

得到它的工作

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
于 2017-09-26T20:22:28.733 回答