# 關於數據庫光標的一些問題,向各位大蝦請教

smzdg 2004-11-25 03:53:46

create PROCEDURE p_iqc_check_mova
@vendno char(10) ,
@pno char(24),
@pageNo int = 1,
@row_in_page int = 20
as
Declare @first int

begin

delete from iqc_check_tmp

select @first =(@pageNo-1)*@row_in_page
if(@first < 0) select @first = 0

declare check_record cursor for
select seq_no,in_date,qty,check_mode,iqcno,iqc_result,other,remark1,remark2,ent_by,ent_date
from dbo.iqc_check
where vendno=@vendno and
pno=@pno
order by in_date Desc,seq_no Desc

open check_record
set cursor rows 1 for check_record

Declare @seq_no int,@in_date datetime,@qty float,@check_mode char(1),
@iqcno char(10),@iqc_result char(40),@other char(20),
@remark1 char(80),@remark2 char(80),@ent_by char(10),@ent_date datetime
declare @i int
declare @j int
select @i = 0
SELECT @j = 1

while(@@sqlstatus = 0)
begin
if(@first = @i)
begin
while (@j <= @row_in_page )
begin
FETCH check_record
INTO @seq_no,
@in_date,
@qty,
@check_mode,
@iqcno,
@iqc_result,
@other,
@remark1,
@remark2,
@ent_by,
@ent_date

IF (@@sqlstatus <>0 )
break

INSERT INTO iqc_check_tmp
values( @seq_no,
@in_date,
@qty,
@check_mode,
@iqcno,
@iqc_result,
@other,
@remark1,
@remark2,
@ent_by,
@ent_date)

SELECT @j=@j+1

END
break
END

FETCH check_record
INTO @seq_no,
@in_date,
@qty,
@check_mode,
@iqcno,
@iqc_result,
@other,
@remark1,
@remark2,
@ent_by,
@ent_date

select @i = @i + 1
end

close check_record
deallocate cursor check_record

end
;
...全文
51 点赞 收藏 2

2 条回复

WorldMobile 2004-11-25
balloonman2002兄说的有理，看看你是不是缺了Dll或者是配置错误

balloonman2002 2004-11-25

738

PowerBuilder 数据库相关

2004-11-25 03:53