我想从db2文件中提取数据,并将它们以.json格式写入IFS。
BEGIN
CALL QSYS2.IFS_WRITE(
PATH_NAME =>'/myIFSdir/testout.txt',
LINE => '',
OVERWRITE => 'REPLACE',
END_OF_LINE => 'NONE',
FILE_CCSID => 1208);
FOR select btbnbr as a
from gldbfa/glpbt
where btbnbr in (241858, 241934, 241983, 242534, 242538, 242657, 242708, 242717, 242723)
DO
CALL QSYS2.IFS_WRITE(
PATH_NAME => '/myIFSdir/testout.txt',
LINE => a,
FILE_CCSID => 1208);
END FOR;
END;
但是,当添加json格式时,它不再工作并产生错误。
BEGIN
CALL QSYS2.IFS_WRITE(
PATH_NAME =>'/myIFSdir/testout.json',
LINE => '',
OVERWRITE => 'REPLACE',
END_OF_LINE => 'NONE',
FILE_CCSID => 1208);
FOR select
json_object('top' value (json_arrayagg(
json_object ('number' value btbnbr)
))) as a
from gldbfa/glpbt
where btbnbr in (241858, 241934, 241983, 242534, 242538, 242657, 242708, 242717, 242723)
DO
CALL QSYS2.IFS_WRITE(
PATH_NAME => '/myIFSdir/testout.json',
LINE => a,
FILE_CCSID => 1208);
END FOR;
END;
错误为:
SQL State: 42904
Vendor Code: -7032
Message: [SQL7032] SQL procedure, function, trigger, or variable *N in *N not created. Cause . . . . . : SQL procedure, function, trigger, or variable *N in *N, or program for compound (dynamic) statement was not created. The compile was not successful. SQL creates an SQL procedure, function, trigger, variable, or a compound (dynamic) statement as a C program that contains embedded SQL. Errors not found during the initial parsing of the CREATE PROCEDURE, ALTER PROCEDURE, CREATE FUNCTION, ALTER FUNCTION, CREATE TRIGGER, CREATE VARIABLE, or compound (dynamic) statement can be found during the precompile. Recovery . . . : If a compile error occurred, see the appropriate listing in QSYSPRT. If the SQL precompile failed, there is always a listing with the error. If the C compile failed, the listing is only created if requested. Specify SET OPTION OUTPUT=*PRINT prior to the routine body in the CREATE PROCEDURE, CREATE FUNCTION, or CREATE TRIGGER statement if listings are required. To see these errors for a compound (dynamic) statement, temporarily change it to a CREATE PROCEDURE statement.
我在V7R3M0上
PTF SF99703为22级
- 感谢所有帮助 *
2条答案
按热度按时间o4hqfura1#
生成的C代码似乎试图创建一个可以接收
a
的结构体,但该结构体太大如果你需要一个那么大的clob,那么我认为你必须问IBM,或者使用declare/open/fetch cursor(它将使用一个定位器)
但如果没有,如果15 M足够,您可以
CAST(... AS CLOB(15M))
pzfprimi2#
一旦切换到
json_arrayagg
,就不需要for
循环了。json_object
或json_arrayagg
的整个选择可以指定为ifs_write
过程的line
参数的值。