create or replace procedure p_lx is
begin
UPDATE AB01_QHD1 t set t.w =1 where t.name in (select t.name from AB01_QHD1 t,AA01_QHD2 t2 where t.name=t2.name);
commit;
end p_lx;
用游标写怎么写 实现上面的代码
create or replace procedure p_lx is
begin
UPDATE AB01_QHD1 t set t.w =1 where t.name in (select t.name from AB01_QHD1 t,AA01_QHD2 t2 where t.name=t2.name);
commit;
end p_lx;
用游标写怎么写 实现上面的代码
create procedure p_lx
as
begin
declare @bianliang varchar(50) ;
set @bianliang='';
declare cur cursor fast_forward for
select t.name from AB01_QHD1 t join AA01_QHD2 t2 on t.name=t2.name
open cur
fetch next from cur into @bianliang
while @@fetch_status=0
begin
UPDATE AB01_QHD1 set w =1 where name=@bianliang
fetch next from cur into @bianliang
end
close c ur
deallocate cur
end
go
这是SQL SERVER的实现方式。你这个不需要写存储过程或者游标的。