标题: DB2 存储过程问题 [打印本页] 作者: lixiuxi2001 时间: 2008-02-02 12:43 标题: DB2 存储过程问题 我的存储过程是这样的,且创建成功
drop procedure pur_rev @
CREATE PROCEDURE pur_rev(in return_code int,in merchant char(16) ,in term char(9),in batch char(9),in trace char(9),out re_code int)
RESULT SETS 1
LANGUAGE SQL
BEGIN
DECLARE SQLCODE INTEGER DEFAULT 0;
DECLARE SQLSTATE CHAR(5) DEFAULT '00000';
declare count_t int default 0;
DECLARE EXIT HANDLER FOR SQLEXCEPTION,NOT FOUND
BEGIN
set re_code=SQLCODE;
rollback;
END;
select count into count_t from pur_rev where batch_no=batch and merchant_no=merchant and term_id=term and cups_no=trace;
if (count_t+1=1) then
if (return_code!=0) then
update pur_rev set count=1 where batch_no=batch and merchant_no=merchant and term_id=term and cups_no=trace;
end if;
if(return_code=0) then
update cups_flows set count=count_t+1,flag='01',resp_no='00' where batch_no=batch and merchant_no=merchant and term_id=term and cups_no=trace;
delete from pur_rev where batch_no=batch and merchant_no=merchant and term_id=term and cups_no=trace;
end if;
end if;
if (count_t+1=2) then
if(return_code!=0) then
update pur_rev set count=count_t+1 where batch_no=batch and merchant_no=merchant and term_id=term and cups_no=trace;
end if;
if(return_code!=0) then
update cups_flows set count=count_t+1,flag='01',resp_no='00' where batch_no=batch and merchant_no=merchant and term_id=term and cups_no=trace;
delete from pur_rev where batch_no=batch and merchant_no=merchant and term_id=term and cups_no=trace;
end if;
end if;
if (count_t+1=3) then
if(return_code!=0) then
update cups_flows set count=count_t+1,flag='01',resp_no='00' where batch_no=batch and merchant_no=merchant and term_id=term and cups_no=trace;
delete from pur_rev where batch_no=batch and merchant_no=merchant and term_id=term and cups_no=trace;
end if;
if(return_code!=0) then
update cups_flows set count=count_t+1,flag='01',resp_no='00' where batch_no=batch and merchant_no=merchant and term_id=term and cups_no=trace;
delete from pur_rev where batch_no=batch and merchant_no=merchant and term_id=term and cups_no=trace;
end if;
end if;
commit;
set re_code=SQLCODE;
END @
但是编译的时候报:
db2inst1@linux-jyt:~/EHome/cupsp/rev> make
db2 connect to ehm_db user db2inst1 using 123456
Database Connection Information
Database server = DB2/LINUX 8.2.0
SQL authorization ID = DB2INST1
Local database alias = EHM_DB
db2 prep rev_trade.sqc bindfile
LINE MESSAGES FOR rev_trade.sqc
------ --------------------------------------------------------------------
SQL0060W The "C" precompiler is in progress.
105 SQL0324N The "host" variable ":rev.merchant_no" is the
wrong type.
SQL0095N No bind file was created because of previous
errors.
SQL0091W Precompilation or binding was ended with "2"
errors and "0" warnings.
make: *** [rev_trade] Error 4
db2inst1@linux-jyt:~/EHome/cupsp/rev>