MSSQL
declare @Var1 varchar(30)
declare my_cursor cursor for select Cloum1 from Table1 where GoodsMovementid=@GoodsmovementID
set @Var2=(select Cloum2 from Table2 where ....)
open my_cursor
fetch from my_cursor into @Var1 while @@FETCH_STATUS=0/*打开并指向第一行*/
begin
if(@Var1 ='0.00000000')begin
something you want to do
end
else
begin
fetch next from my_cursor into @Var1 ;/*打开并指向下一行*/
endend
close my_cursor
DEALLOCATE my_cursor
Oracle
Cursor getrecorde is select TaxExPrice from GoodsMovementItem where GoodsMovementid=p_GoodsmovementID;
Var1 NUMBER(20,8);
Var2 Varchar2(50);
BEGIN
select Cloum1 into Var1 from Table1 where ....;
if (Var1 ='201')then
open getrecorde ;
loop
fetch getrecorde into TaxPrice;
exit when getrecorde%notfound;
you want to do......
end loop;
close getrecorde;
end if;
end loop;
close getrecorde;
end if;