db2 在FUNCTION中引用DGTT(声明的全局临时表)时为SQL0526N

x0fgdtte  于 2022-11-07  发布在  DB2
关注(0)|答案(1)|浏览(254)

我想从预先创建的DGTT中返回内容作为表函数的结果集。
但是当我引用它时,我得到了SQL SQL 0526 N/ SQLSTATE 42995错误。
我看不出为什么。Documentation只显示42995 sqlstate错误的3个原因:

Restrictions on the use of declared temporary tables: Declared temporary tables cannot:
- Be specified in an ALTER, COMMENT, GRANT, LOCK, RENAME or REVOKE statement (SQLSTATE 42995).
- Be referenced in an AUDIT, CREATE ALIAS, or CREATE VIEW statement (SQLSTATE 42995).
- Be specified in referential constraints (SQLSTATE 42995).

但是它们都没有被使用..函数非常简单:

BEGIN  ATOMIC 

    CALL DBAREP.SP_ROW_CHECKSUM(sSchema, sTable, sColumnList, sWhere, iRows) ;     

    RETURN 
         (SELECT * FROM SESSION.DBAREP_ROW_CHECKSUM ) ;
END@

我这次违反了什么规则?

a1o7rhls

a1o7rhls1#

文档中确实没有明确说明,但是Declared GTT不能用在内联的复合语句中(带有开始ATOMIC ... END)。
您可以改为在内联复合语句中使用Created GTT。

相关问题