在oracle要写这样一个存储过程,不知为什么老是报错,求解答?
createorreplaceprocedurepriceplanpro(nstartinnumber,noidinnumber,planinnumber)asbegin...
create or replace procedure priceplanpro
(nstart in number,noid in number,plan in number)
as
begin
if nstart > 0 then
update priceplan r inner join ductprice p on r.ncorp=p.ncorp
set p.nprice= plan where noid = noid and start=nstart and nsta = 2021;
end if;
exception
when no_data_found then
dbms_output.put_line('数据不存在!');
end priceplanpro; 展开
(nstart in number,noid in number,plan in number)
as
begin
if nstart > 0 then
update priceplan r inner join ductprice p on r.ncorp=p.ncorp
set p.nprice= plan where noid = noid and start=nstart and nsta = 2021;
end if;
exception
when no_data_found then
dbms_output.put_line('数据不存在!');
end priceplanpro; 展开
2个回答
展开全部
那段update语句改成如下语句
merge priceplan r
using ductprice p
on (r.ncorp=p.ncorp and r.noid = p.noid and r.start=p.nstart and r.nsta = 2021)
when matched then
update
set p.nprice= plan
;
merge priceplan r
using ductprice p
on (r.ncorp=p.ncorp and r.noid = p.noid and r.start=p.nstart and r.nsta = 2021)
when matched then
update
set p.nprice= plan
;
展开全部
Oracle中没有Update from 的语法
create or replace procedure priceplanpro
(nstart in number,noid in number,plan in number)
as
begin
if nstart > 0 then
update ductprice p set p.nprice= plan
where noid = noid and start=nstart and nsta = 2021
and exists(select * from priceplan r where r.ncorp=p.ncorp) ;
end if;
exception
when no_data_found then
dbms_output.put_line('数据不存在!');
end priceplanpro;
create or replace procedure priceplanpro
(nstart in number,noid in number,plan in number)
as
begin
if nstart > 0 then
update ductprice p set p.nprice= plan
where noid = noid and start=nstart and nsta = 2021
and exists(select * from priceplan r where r.ncorp=p.ncorp) ;
end if;
exception
when no_data_found then
dbms_output.put_line('数据不存在!');
end priceplanpro;
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询