日期:2014-05-17  浏览次数:20756 次

初步接触oracle,不知道存储过程怎么改?
sql   server的存储过程要改成oracle的


create     procedure   spp_freecond_commit(@POPNo   varchar(11),@intCount   int   output)
as
declare   @CommitTrainning   int                                                              

declare   @CommitOther int

select   @CommitTrainning=sum(UnitReserve*quantity)     from   TTQ_CommitTrainning   where   POPNo=@POPNo
select   @CommitOther=sum(Reserve)     from   TTQ_CommitOtherOffer   where   POPNo=@POPNo

if   @CommitTrainning> 0   or   @CommitOther> 0  
select   @intCount=1
else
select   @intCount=0

return   @intcount

我现在改成这样,可是报错,大家帮我看看,多谢了

create   or   replace   procedure   test_spp_freecond_commit(POPNo   in   varchar2(11),intCount     out   number)   is
begin

CommitTrainning   number;                                                                  

CommitOther number;


select   sum(UnitReserve*quantity)   into   CommitTrainning   from   TTQ_CommitTrainning   where   POPNo=POPNo;
select   sum(Reserve)   into   CommitOther   from   TTQ_CommitOtherOffer   where   POPNo=POPNo;

if   CommitTrainning> 0   or   CommitOther> 0   then
intCount:=1;
else
intCount:=0;
end   if;

   
end   test_spp_freecond_commit;


------解决方案--------------------
我的异常网推荐解决方案:oracle存储过程,http://www.aiyiweb.com/oracle-develop/177537.html
------解决方案--------------------
create or replace procedure test_spp_freecond_commit(p_POPNo in varchar2,intCount out number) is
CommitTrainning number;
CommitOthernumber;
begin

select sum(UnitReserve*quantity) into CommitTrainning from TTQ_CommitTrainning where POPNo=p_POPNo;
select sum(Reserve) into CommitOther from TTQ_CommitOtherOffer where POPNo=p_POPNo;

if CommitTrainning> 0 or CommitOther> 0 then
intCount:=1;
else
intCount:=0;
end if;

end test_spp_freecond_commit;