I am trying to print the value of variable @NonSmoker by reading this float value from a table using a cursor. The print statement isn't returning anything. It seems the cursor isn’t reading or storing any values for @NonSmoker. What could the problem be?? Here is my script;
create procedure smoking_history as
begin
declare @NonSmoker int, @ID int
set @NonSmoker=0
set @ID=0
declare smokinghistory_cursor cursor for
select C.ID, D.NonSmoker from CView C
inner join TestCases D on C.RefNbr=D.IDNbr;
open smokinghistory_cursor
fetch next from smokinghistory_cursor into @ID, @NonSmoker
while @@fetch_status=0
begin
print @NonSmoker
fetch next from smokinghistory_cursor into @ID, @NonSmoker
end
close smokinghistory_cursor
deallocate smokinghistory_cursor
end
create procedure smoking_history as
begin
declare @NonSmoker int, @ID int
set @NonSmoker=0
set @ID=0
declare smokinghistory_cursor cursor for
select C.ID, D.NonSmoker from CView C
inner join TestCases D on C.RefNbr=D.IDNbr;
open smokinghistory_cursor
fetch next from smokinghistory_cursor into @ID, @NonSmoker
while @@fetch_status=0
begin
print @NonSmoker
fetch next from smokinghistory_cursor into @ID, @NonSmoker
end
close smokinghistory_cursor
deallocate smokinghistory_cursor
end