MySQL Forums
Forum List  »  Microsoft SQL Server

Re: How can I declare a global cursor ?
Posted by: fatemeh karampanah
Date: April 21, 2006 11:25PM

I have a global cursor that when we call the store procedure ,
it load next 100 record from table and position move forward:

this is part of code:



if(@del=0 and @code=0)
begin
declare Alv_lvl1cursor cursor scroll static global for
select AlarmLevel,AlarmType,AlarmReason,AlarmNumber,
DATEPART(yyyy,AlarmTime) as Alyear,
DATEPART(mm,AlarmTime) as Almonth,
DATEPART(dd,AlarmTime) as Alday,
DATEPART(hh,AlarmTime) as Alhour,
DATEPART(mi,AlarmTime) as Almin,
LTRIM(RTRIM(AlarmDescription)),
AlarmRecovery
from AlarmTable
where AlarmLevel=@Lev
order by AlarmTime desc ,AlarmNumber
set @i=0
open Alv_lvl1cursor
if(@next=1)
begin
while (@i < 100 )
begin
fetch next from Alv_lvl1cursor
if (@@FETCH_STATUS <> 0)
begin
close Alv_lvl1cursor
deallocate Alv_lvl1cursor
return
end
set @i=@i+1
end
end
else
begin
while (@i < 100 )
begin
fetch prior from Alv_lvl1cursor
if (@@FETCH_STATUS <> 0)
begin
close Alv_lvl1cursor
deallocate Alv_lvl1cursor
return
end
set @i=@i+1
end
end
end



Edited 1 time(s). Last edit at 04/21/2006 11:33PM by fatemeh karampanah.

Options: ReplyQuote


Subject
Written By
Posted
Re: How can I declare a global cursor ?
April 21, 2006 11:25PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.