Re: EXEC statement inside cursor iteration (@@fetch_status =0)
From: Jacco Schalkwijk (NOSPAMjaccos_at_eurostop.co.uk)
Date: 04/20/04
- Next message: Jordy: "Possible?"
- Previous message: Prabhat: "Re: Multiuser Problem"
- In reply to: R. Z.: "EXEC statement inside cursor iteration (@@fetch_status =0)"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 20 Apr 2004 14:22:26 +0100
Why do you need a cursor? Is the code in the stored procedure that complex?
Things will be easier and a lot quicker if you don't use a cursor and use
proper SQL instead. If you post your code on here, someone will help you
with that.
Anyways, @@cursor_fetch is not correct Microsoft SQL Server syntax, it's
@@FETCH_STATUS. So if you are actually on a different database platform
(Sybase?), it might more useful to post your questions in forum specific to
that product.
-- Jacco Schalkwijk SQL Server MVP "R. Z." <bob_whale@yahoo.com> wrote in message news:34b831f2.0404200357.60733429@posting.google.com... > I 've have a stored procedure that compares fields across databases. > In order to do so it requires 2 values it acquires from 2 tables. The > search is based on the ID of the data owner and a subject: > > proc_evaluate_results @StudentId = '222222', Course = 'PSY101' > > In order to obtain those values I run a cursor accross my records and > SELECT THEM INTO 2 @variables, which then replace 222222 and PSY101 > with dynamic values eg. > > --define a cursor etc.etc. > > WHILE @@cursor_fetch = 0 > BEGIN > --do the cursor call INTO @vars > EXEC proc_evaluate_results @StudentId = @studentID, @Course = > @CourseCode > END > > Now,the vars are being passed to the stored procedure and executed OK, > but the cursor gets stuck on the last record and continues to evaluate > it until stopped manually. > > If I comment out the EXEC and replace it with eg. PRINT @Course + ' | > ' + @CourseCode it runs fine, exiting after the last record. > > > Thanks > R>
- Next message: Jordy: "Possible?"
- Previous message: Prabhat: "Re: Multiuser Problem"
- In reply to: R. Z.: "EXEC statement inside cursor iteration (@@fetch_status =0)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|