sql 存储过程if not exists 转换成oracle
这是sql的存储过程要转换成oracle,麻烦亲帮忙转换一下我转换了一直出错,ALTERproc[dbo].[leibie_del]@leibieidintasifnot...
这是sql的存储过程要转换成oracle ,麻烦亲帮忙转换一下 我转换了一直出错 ,
ALTER proc [dbo].[leibie_del]
@leibieid int
as
if not exists(select shangpingid from shangping where leibieid = @leibieid)
delete leibie where leibieid = @leibieid
这是我转换的 :
create or replace
PROCEDURE LEIBIE_DEL
(
ret out sys_refcursor,
I_LEIBIEID IN INT
) AS
BEGIN
open ret for
select shangpingid from shangping
when (not exists(select *from shangping where leibieid = i_leibieid))
then
delete leibie where leibieid = i_leibieid;
END LEIBIE_DEL; 展开
ALTER proc [dbo].[leibie_del]
@leibieid int
as
if not exists(select shangpingid from shangping where leibieid = @leibieid)
delete leibie where leibieid = @leibieid
这是我转换的 :
create or replace
PROCEDURE LEIBIE_DEL
(
ret out sys_refcursor,
I_LEIBIEID IN INT
) AS
BEGIN
open ret for
select shangpingid from shangping
when (not exists(select *from shangping where leibieid = i_leibieid))
then
delete leibie where leibieid = i_leibieid;
END LEIBIE_DEL; 展开
1个回答
展开全部
create or replace procedure LEIBIE_DEL(p_leibieid shangping.leibieid%type) is
begin
delete leibie l
where not exists (select 'x'
from shangping s
where s.leibieid = l.leibieid
and s.leibieid = p_leibieid);
END LEIBIE_DEL;
将leibieid作为参数传入,如果在shangping表里没有该id信息,就删除leibie表里的id信息。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询