curson does not closed correctly

J

jerry

I have a access 2000 project(adp) connect to sql 2000
backend. I created a stored procedure in sql server, it
runs correctly in query analyzer, but it does not run
correctly in adp given the same parameter, running on the
same machine. Does any one know why the curson could
closed even it is not reached the end?

Here is the stored procedure,
CREATE PROCEDURE zzzz_test
(
@fiscal_year int,
@subcat_id int,
@salarygroup varchar(20),
@selectedDiv int,
@userid varchar(20)
)
AS

declare @source int
declare @staffname varchar(100)
declare @description varchar(200)
declare @tbaname varchar(100)
declare @div varchar(100)
declare @salaryID int
declare @sum_all money
declare @count int

delete from budget_salary where salarygroup=@salarygroup
and userid=@userid

declare salary_cursor cursor for
select staffname, description, sum
(current_year_budget), source_id, division_title FROM
qryshowcategorybudgetall
WHERE subcategory_id=@subcat_id and
FISCAL_YEAR=@fiscal_year and (not(staffname is null))
GROUP BY staffname, description, source_id,
division_title order by staffname

open salary_cursor

fetch next from salary_cursor into @staffname,
@description, @sum_all, @source, @div
select @count=1
--while (@@fetch_status =0 )
while(@count<200)
begin

INSERT INTO ZZZTEMP (staffname,status) VALUES (
@staffname,@@fetch_status)

fetch next from salary_cursor into
@staffname, @description, @sum_all, @source, @div
select @count=@count+1
end

close salary_cursor
deallocate salary_cursor
GO
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top