请问个ORACLE存储过程的问题

row32hahaha 2009-09-08 04:34:46
IF PAUDIT='V' then

下面我接了一句update语句。但提示有错
错误如下:

PROCEDURE SALER.PROC_AUDITFLOW 编译错误

错误:PLS-00103: 出现符号 "IF"在需要下列之一时:
:= . ( @ % ;
符号 ";" 被替换为 "IF" 后继续。
行:20
文本:if PAUDIT='V' then


请问IF then 后面只能接哪些语句?还有这个错误是什么问题?
...全文
104 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
shiyiwan 2009-09-08
  • 打赏
  • 举报
回复
if v_text = 'V' then
update test t1
SET t1.text=PAUDIT

这个应该是v_text
ojuju10 2009-09-08
  • 打赏
  • 举报
回复
if PAUDIT='V' then

update test t1
SET t1.text=PAUDIT
where exists(select 1
from ApplyInfo t2, AuditFlow t3
where t1.AppID = t2.ID
and t2.ID = t3.ApplyID(+)
and t3.id = PID);
end if; --缺少end if;

如果编译不通过,请单独调试UPdate语句
row32hahaha 2009-09-08
  • 打赏
  • 举报
回复
感谢,辛苦了。我去试试
shiyiwan 2009-09-08
  • 打赏
  • 举报
回复

Create PROCEDURE dbo.proc_texttest (
v_id in number,
v_text in char(1),
v_opinion in varchar2(500)
)
as

v_applyID number;
v_textSerial number;
v_flag number := 0;
begin

select ApplyID, textSerial
into v_applyID, v_textSerial
from textFlow
where id = v_id;

if v_text = 'V' then
update test t1
SET t1.text=PAUDIT
where exists( select 1
from ApplyInfo t2, AuditFlow t3
where t1.AppID = t2.ID
and t2.ID = t3.ApplyID(+)
and t3.id = v_id);

else if v_text = 'Y' then

select count(id) into v_flag from textFlow where ApplyID = v_applyID and textSerial > v_textSerial;

if v_flag = 0 then
update UserApplyInfo set state = v_text where ID = v_applyID;
update test set text = v_text where AppID =v_applyID;
else
update textFlow set ArriveDate=sysdate where ApplyID = v_applyID and textSerial=v_textSerial+1;
end if;

else if v_text='N' then
select count(id) into v_flag
from textFlow
where ApplyID = v_applyID
and textSerial > v_textSerial
and text <> 'N';

if v_flag > 0 then
dbms_output.put_line('无法审核!');
else
select count(id) into v_flag
from textFlow
where ApplyID = v_applyID
and textSerial > v_textSerial
and text='N';

if v_flag > 0 then
update UserApplyInfo set state=v_text where id = v_id;
update test set text=v_text where AppID=v_applyID;
end if;
end if;
end if;

update textFlow set text=v_text,Opinion=v_opinion,FinishDate=sysdate where id = v_id;

exception
when others then
rollback;
raise;
end proc_texttest;
row32hahaha 2009-09-08
  • 打赏
  • 举报
回复

Create PROCEDURE [dbo].[proc_texttest]
@ID int,
@text char(1),
@Opinion nvarchar(500)
as

declare @ApplyID int,@textSerial int

select @ApplyID=ApplyID,@textSerial=textSerial
from textFlow
where ID=@ID

BEGIN TRAN

if(@text='V')
begin
update test SET text=@text
from test
inner join UserApplyInfo on AppID=UserApplyInfo.ID
left join textFlow on UserApplyInfo.ID=ApplyID
where textFlow.ID=@ID
end

if(@text='Y')
begin

if not exists(select ID from textFlow
where ApplyID=@ApplyID and textSerial>@textSerial)
begin
update UserApplyInfo set state=@text
where ID=@ApplyID
update test set text=@text where AppID=@ApplyID
end
else
begin
update textFlow set ArriveDate=getdate() where
ApplyID=@ApplyID and textSerial=@textSerial+1
end
end

else if(@text='N')
begin
if exists(select ID from textFlow
where ApplyID=@ApplyID and textSerial>@textSerial
and text<>'N')
begin
raiserror('无法审核!',16,1)
return
end
else if exists(select ID from textFlow
where ApplyID=@ApplyID and textSerial>@textSerial
and text='N')
begin
update UserApplyInfo set state=@text
where ID=@ApplyID
update test set text=@text where AppID=@ApplyID
end

end
update textFlow set text=@text,Opinion=@Opinion,FinishDate=getdate()
where ID=@ID
COMMIT TRAN





以上是SQLSERVER2005里的完整存储过程。麻烦各位帮我翻成ORACLE一下,最好麻烦给个
注释说明下,小弟刚接触ORA几天实在感觉很无力。谢谢了
shiyiwan 2009-09-08
  • 打赏
  • 举报
回复
if PAUDIT='V' then

update test t1
SET t1.text=PAUDIT
where exists(select 1
from ApplyInfo t2, AuditFlow t3
where t1.AppID = t2.ID
and t2.ID = t3.ApplyID(+)
and t3.id = PID);
end if;

你好像把test t1写在一起了
liusong_china 2009-09-08
  • 打赏
  • 举报
回复
把整个代码贴出来啊。。。
row32hahaha 2009-09-08
  • 打赏
  • 举报
回复
if PAUDIT='V' then

update testt1
SET t1.text=PAUDIT
where exists(select 1
from ApplyInfo t2, AuditFlow t3
where t1.AppID = t2.ID
and t2.ID = t3.ApplyID(+)
and t3.id = PID);

PAUDIT和PID是存储过程传入的参数
shiyiwan 2009-09-08
  • 打赏
  • 举报
回复
代码全部贴出来吧

这个看不出错误

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧