我有一个表函数,它返回一个表(student_id,student_name)
我想调用它并将结果插入另一个表
我用
INSERT INTO STUDENT_TMP SELECT Table(MyDB.fn_getStudent())
但我没有得到结果 我有一个错误:
ERROR: DB2 SQL Error: SQLCODE=-390, SQLSTATE=42887,
SQLERRMC=MyDB.AA;SQL131208155041300,DRIVER=3.67.26
Error Code: -390
答案 0 :(得分:2)
我在ibm网站上找到了以下示例:
select t1.timeid, t1.storeid, t1.sales
from time, store, table (cvsample.salesfunc(time.timeid, store.storeid)) as t1
where time.timeid = t1.timeid and store.storeid = t1.storeid;
注意语法: table(cvsample.salesfunc(time.timeid,store.storeid))as t1
所以你不需要字段和'as'你还需要'*'和'FROM'
所以
INSERT INTO STUDENT_TMP SELECT * FROM Table (MyDB.fn_getStudent())