-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
--SET NOCOUNT ON;
declare @ignationsize int
declare @speedsize int
declare @uvid int
declare @uname nvarchar(100)
set @uname=@uid
--print @uid
--0 FETCH 语句成功。
--声明一个游标mycursor,select语句中参数的个数必须要和从游标取出的变量名相同
declare mycursor cursor for select mVEHICLE.uvid,mVEHICLE.uid from mVEHICLE where uid=@uname
--打开游标
open mycursor
--从游标里取出数据赋值到我们刚才声明的2个变量中
fetch next from mycursor into @uvid,@uid
while (@@fetch_status=0)
BEGIN
select @speedsize = count(*) from mLOCK where uid=@uid and uvid=@uvid and eventid=3
if(@speedsize=0)
begin
insert into mLOCK (uvid,uid,typeid,eventid,label,status,ignition,lat,lon,radius,speed,priority,geo_type) values(@uvid,@uname,2,3,' ',0,1,0.0,0.0,100,100,0,1)
END
fetch next from mycursor into @uvid,@uid
END
--关闭游标
close mycursor
--撤销游标
deallocate mycursor
END
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[checkPBMLock] //checkPBMLock 存储过程名
(@uid nvarchar(100)) //参数AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
--SET NOCOUNT ON;
declare @ignationsize int
declare @speedsize int
declare @uvid int
declare @uname nvarchar(100)
set @uname=@uid
--print @uid
--0 FETCH 语句成功。
--声明一个游标mycursor,select语句中参数的个数必须要和从游标取出的变量名相同
declare mycursor cursor for select mVEHICLE.uvid,mVEHICLE.uid from mVEHICLE where uid=@uname
--打开游标
open mycursor
--从游标里取出数据赋值到我们刚才声明的2个变量中
fetch next from mycursor into @uvid,@uid
while (@@fetch_status=0)
BEGIN
select @speedsize = count(*) from mLOCK where uid=@uid and uvid=@uvid and eventid=3
if(@speedsize=0)
begin
insert into mLOCK (uvid,uid,typeid,eventid,label,status,ignition,lat,lon,radius,speed,priority,geo_type) values(@uvid,@uname,2,3,' ',0,1,0.0,0.0,100,100,0,1)
END
fetch next from mycursor into @uvid,@uid
END
--关闭游标
close mycursor
--撤销游标
deallocate mycursor
END