Is there anybody who has the experience with SQL Server's Stored Procedure and cousor? Please come in.

cyt (会飞的鹿)
I'm wondering how come I'm not able to fecth the column in the cursor Cur_repnum into the variable @repNum.
Platform is SQL Server 7.0

create PROCEDURE test
@empId VARCHAR
AS
DECLARE @repNum INTEGER

SET @repNum = 0
DECLARE Cur_repnum CURSOR FOR SELECT report_number FROM personal_exp_report_table
WHERE employee_id = @empId order by report_number

OPEN Cur_repnum
FETCH NEXT FROM Cur_repnum INTO @repNum
select 'REPNUM= ' + CONVERT(varchar(9), @repNum)
----WHILE @@FETCH_STATUS=0...
CLOSE Cur_repnum
DEALLOCATE Cur_repnum
GO


exec test 'RD11'

-----------------
REPNUM= 0

(1 row(s) affected)


SELECT report_number FROM personal_exp_report_table
WHERE employee_id = 'RD11' order by report_number

report_number
-------------
8
9
10
11
12
14
15
16

(8 row(s) affected)
(#263571@0)
2001-11-16 -05:00

回到话题: Is there anybody who has the experience with SQL Server's Stored Procedure and cousor? Please come in.

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论

URL:   
http://www.rolia.net/zh/post.php?f=0&p=263571