oracle存储过程转换成sql存储过程 加游标 5
CREATEORREPLACEPROCEDUREUSP_VASCULAR_ACCESS_SITEISBEGINDECLAREV_VASCULAR_ACCESSVARCHA...
CREATE OR REPLACE PROCEDURE USP_VASCULAR_ACCESS_SITE IS
BEGIN
DECLARE
V_VASCULAR_ACCESS VARCHAR2(50);
V_ACCESS_SITE VARCHAR2(50);
BEGIN
FOR BRESULT IN (SELECT A.PATIENT_ID FROM BPIS_PATIENT_INFO A) LOOP
BEGIN
SELECT A.VASCULAR_ACCESS, A.ACCESS_SITE
INTO V_VASCULAR_ACCESS, V_ACCESS_SITE
FROM BPIS_TREAT_PROGRAM_LIST A
WHERE A.PATIENT_ID = BRESULT.PATIENT_ID
AND ROWNUM = 1;
UPDATE BPIS_PATIENT_INFO A
SET A.VASCULAR_ACCESS = V_VASCULAR_ACCESS,
A.ACCESS_SITE = V_ACCESS_SITE
WHERE A.PATIENT_ID = BRESULT.PATIENT_ID;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END LOOP;
END;
END USP_VASCULAR_ACCESS_SITE; 展开
BEGIN
DECLARE
V_VASCULAR_ACCESS VARCHAR2(50);
V_ACCESS_SITE VARCHAR2(50);
BEGIN
FOR BRESULT IN (SELECT A.PATIENT_ID FROM BPIS_PATIENT_INFO A) LOOP
BEGIN
SELECT A.VASCULAR_ACCESS, A.ACCESS_SITE
INTO V_VASCULAR_ACCESS, V_ACCESS_SITE
FROM BPIS_TREAT_PROGRAM_LIST A
WHERE A.PATIENT_ID = BRESULT.PATIENT_ID
AND ROWNUM = 1;
UPDATE BPIS_PATIENT_INFO A
SET A.VASCULAR_ACCESS = V_VASCULAR_ACCESS,
A.ACCESS_SITE = V_ACCESS_SITE
WHERE A.PATIENT_ID = BRESULT.PATIENT_ID;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END LOOP;
END;
END USP_VASCULAR_ACCESS_SITE; 展开
1个回答
2016-05-04 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
关注
展开全部
CREATE proc jiagongzi
as
declare @name nvarchar(20)
declare @xueli nvarchar(20)
declare @time datetime
declare @gongzi intdeclare zengjia cursor scroll
for
select * from 职员表
open zengjia
fetch next from zengjia into @name,@xueli,@time,@gongzi
while @@FETCH_STATUS=0
begin
if (@xueli='本科' or @xueli='硕士') and DATEDIFF(year, @time, getdate())>=3
begin
update 职员表 set 工资=@gongzi+@gongzi*0.1 where 姓名=@name
end
if (@xueli<>'本科' and @xueli<>'硕士') and DATEDIFF(year, @time, getdate())>=10
begin
update 职员表 set 工资=@gongzi+@gongzi*0.08 where 姓名=@name
end
fetch next from zengjia into @name,@xueli,@time,@gongzi
end
close zengjia
deallocate zengjia goexec jiagongzi
as
declare @name nvarchar(20)
declare @xueli nvarchar(20)
declare @time datetime
declare @gongzi intdeclare zengjia cursor scroll
for
select * from 职员表
open zengjia
fetch next from zengjia into @name,@xueli,@time,@gongzi
while @@FETCH_STATUS=0
begin
if (@xueli='本科' or @xueli='硕士') and DATEDIFF(year, @time, getdate())>=3
begin
update 职员表 set 工资=@gongzi+@gongzi*0.1 where 姓名=@name
end
if (@xueli<>'本科' and @xueli<>'硕士') and DATEDIFF(year, @time, getdate())>=10
begin
update 职员表 set 工资=@gongzi+@gongzi*0.08 where 姓名=@name
end
fetch next from zengjia into @name,@xueli,@time,@gongzi
end
close zengjia
deallocate zengjia goexec jiagongzi
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询