informix 存储过程问题,救命啊!!
DROP PROCEDURE upjxfhz;CREATE PROCEDURE upjxfhz(acZh char(22)) returning integer;
define sql_err int;
define isam_err int;
define sql_text char(100);
define fh_zh char(22);
define fh_jgm char(8);
define fh_bzh char(2);
define iRows int ;
on exception set sql_err, isam_err, sql_text
returnsql_err;
end exception;
set debug file to "pro.log";
trace on;
foreach jxfhz_cur for
select jgm,bzh into fh_jgm,fh_bzh
from fhz
where acct = acZh
let iRows = dbinfo("sqlca.sqlerrd2");
if iRows!= 1 then
returnsql_err;
end if;
end foreach;
trace off;
return 0;
END PROCEDURE;
错误如下 696 :
trace on
start select cursor.
"0$jxfhz_cur" is select jgm, bzh
from fhz
where (= zh, aczh)
select cursor iteration.
select cursor returns 01010102 , 01
expression:(dbinfo-sqlca.sqlerrd2 )
evaluates to 0
let irows = 0
expression:(<> irows, 1)
evaluates to t
exception : looking for handler
SQL error = -696 ISAM error = 0error string == "sql_err"
exception : handler FOUND
expression:sql_err
evaluates to -696
procedure upjxfhz returns -696
怎么办啊,?????
调用程序是:
strcpy( acZh,"0101010101101000080026");
EXEC SQL EXECUTE PROCEDURE upjxfhz(:acZh) INTO :iErrCode;
if( iErrCode || sqlca.sqlcode )
{
printf( "程序失败[%d][%d]\n",iErrCode,sqlca.sqlcode ) ;
return -1;
} if iRows!= 1 then
returnsql_err;
这里的sql_err 并没有赋值,你可以在定义的时候给它个默认值好了。。
页:
[1]