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)
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)