我自己做了个销售图书的软件,用的数据库为sql server2000 sp3a,里面用到了一个游标,
DECLARE cp_cur CURSOR FOR
SELECT book_sale.book_shuliang, book_sale.book_isbn FROM book_sale WHERE book_sale.sale_lsh = :ls_book_lsh;
open cp_cur;
fetch cp_cur into:ld_book_shuliang,:ls_book_isbn;
do while sqlca.sqlcode = 0
SELECT book_ck.book_shuliang INTO :ld_shuliang FROM book_ck WHERE book_ck.book_isbn = :ls_book_isbn ;
ld_zong = ld_shuliang - ld_book_shuliang
UPDATE book_ck SET book_shuliang = :ld_zong WHERE book_ck.book_isbn = :ls_book_isbn ;
fetch cp_cur into :ld_book_shuliang,:ls_book_isbn;
loop
close cp_cur;
现在出现了问题,为什么第一次循环时ld_shuliang老为零,而下面的不论循环多少次就可以准确的检索出数来,在DEBUG下测试时,第一次循环ls_book_isbn也有值,相应的数据库中也有对应值,另外在sybase anywhere 下不出这种错误。请大家看一下。
为什么游标会这样,还是PB的原因