The view being compiled is based on other view which contain a function that has the return parameter VARCHAR(32672).
SQLLIB\BIN> db2 list tablespaces show detail表空间标识 = 1名称 = TEMPSPACE1类型 = 系统管理空间内容 = 系统临时数据......页大小(以字节计) = 4096......I tried to reduce the return parameter length down to 4005 in the function, but the error continues to happen as compiling the view. Finally it works for VARCHAR(3600) as maximum.
Please see following test case.
The function.CREATE FUNCTION zytst.fun1RETURNS VARCHAR(32672)LANGUAGE SQLDETERMINISTICNO EXTERNAL ACTIONREADS SQL DATARETURN 'abc'@
The inner view.
CREATE VIEW zytst.v1 ASVALUES zytst.fun1() AS c1@
The view occurring error.
CREATE VIEW zytst.v2 ASSELECT c1 AS c1 FROM zytst.v1@
The function fun1 and the view v1 could be compiled successfully in the DB whose system temporary tablespace only has 4KB pagesize in bufferpool. But the v2 could Not be compiled in the same DB.
解决方法参考:
http://blog.sinzy.net/richard/entry/6679
create bufferpool ibmdefault8k IMMEDIATE SIZE 5000 PAGESIZE 8 K ;
再创建一个系统临时表空间才能让DB2 shut up.
CREATE TEMPORARY TABLESPACE mysystmp1
IN DATABASE PARTITION GROUP IBMTEMPGROUP
PAGESIZE 8K
MANAGED BY SYSTEM
USING
('D:\DB2\mysapce'
)
EXTENTSIZE 32
PREFETCHSIZE 16
BUFFERPOOL IBMDEFAULT8K
OVERHEAD 24.10
TRANSFERRATE 0.90
DROPPED TABLE RECOVERY OFF;
然后,使用该缓冲池创建一个表空间
CREATE TABLESPACE mytbs
IN DATABASE PARTITION GROUP IBMDEFAULTGROUP
PAGESIZE 8K
MANAGED BY SYSTEM
USING
('D:\DB2\mytables'
)
EXTENTSIZE 32
PREFETCHSIZE 16
BUFFERPOOL IBMDEFAULT8K
OVERHEAD 24.10
TRANSFERRATE 0.90
DROPPED TABLE RECOVERY OFF;
GRANT USE OF TABLESPACE mytbs TO PUBLIC;