好的,所以我有点困惑。我用一个程序创建了一个简单的模块。当内部包含原型和数据结构时,它就像一个魅力......
ctl-opt option(*srcstmt:*nodebugio) nomain ;
dcl-ds IIM ext end-ds;
dcl-pr GetIIM LikeDS(IIM);
*n char(35) options(*nopass) value ;
end-pr ;
dcl-proc GetIIM export ;
dcl-pi *n LikeDS(IIM);
Item char(35) options(*nopass) value ;
end-pi ;
exec sql
select * into :IIM
from iim where iprod=:ITEM;
return IIM ;
end-proc ;
但是当我使用/ copy时,SQL编译器不喜欢数据结构并给我一个错误...
原型
/if defined(GetIIM)
dcl-ds IIM ext end-ds;
dcl-pr GetIIM LikeDS(IIM);
*n char(35) options(*nopass) value ;
end-pr ;
/endif
程序
ctl-opt option(*srcstmt:*nodebugio) nomain ;
/define GetIIM
/copy JAGRACE/SANDBOX3,prototype
/undefine GetIIM
dcl-proc GetIIM export ;
dcl-pi *n LikeDS(IIM);
Item char(35) options(*nopass) value ;
end-pi ;
exec sql
select * into :IIM
from iim where iprod=:ITEM;
return IIM ;
end-proc ;
程序
那么,我现在做的是什么蠢事?错误代码为 SQL 0312变量IIM未定义或不可用。
我认为/ copy基本上会将该代码段放入源代码并进行编译。我知道SQL预编译器有问题,但我迷路了......
答案 0 :(得分:5)
查看Create SQL ILE RPG对象(CRTSQLRPGI)命令的RPG预处理器选项(RPGPPOPT)参数。
在线帮助...
RPG预处理器选项(RPGPPOPT)
Specifies if the ILE RPG compiler will be called to preprocess the source member before the SQL precompile is run. Preprocessing the SQL source member will allow some compiler directives to be handled before the SQL precompile. The preprocessed source will be placed in file QSQLPRE in QTEMP. This source will be used for the SQL precompile. *NONE The compiler is not called for preprocessing. *LVL1 The compiler is called for preprocessing to expand /COPY and handle the conditional compilation directives except the /INCLUDE directive. *LVL2 The compiler will be called for preprocessing to expand /COPY and /INCLUDE and handle the conditional compilation directives.
确保您没有使用*无。