我被要求编写一个简单的过程,它在证明条件下向表中插入一个新行。 数据库: 表用户 - USER_ID .... 表曲目 - track_id .... 表喜欢 - USER_ID,track_idPL/SQL ERROR无法识别错误是什么,PSL-00103
程序必须确保用户在用户,轨道是轨道,但两者都不会出现在喜欢的表的相同记录中。
不知道错误来自哪里,请帮忙!错误的
列表: 错误(72,1):PLS-00103:出现符号 “申报单” 错误(77.4):PLS-00103:出现符号 “档案结尾” 预期时下列之一:(开始的情况下宣告结束退出异常的转到如果环模空编译提高收益选择更新而与<
create or replace Procedure proc_insert_liked
(p_userID IN liked.user_id%TYPE , p_trackID IN liked.track_id%TYPE)
AS
test1 liked.user_id%TYPE;
test2 liked.track_id%TYPE;
test3 tracks.track_id%Type;
test4 users.user_id%Type;
cursor c1 is
Select user_id
from liked
where user_id = p_userID;
cursor c2 is
Select track_id
from liked
where track_id = p_trackID;
cursor c3 is
Select track_id
from tracks
where track_id = p_trackID;
cursor c4 is
Select user_id
from users
where user_id = p_userID;
Begin
--opening cursors
open c1;
open c2;
open c3;
open c4;
fetch c1 into test1;
fetch c2 into test2;
fetch c3 into test3;
fetch c4 into test4;
-- if user and track in liked
if (c1%found) AND (c2%found) then
dbms_output.put_line('User already liked that song');
else
-- if track in tracks
if c3%found then
-- if user in users
if c4%found then
Insert into Liked (user_id, track_id)
Values (p_userId, p_trackID);
else
dbms_output.put_line('no such a user');
end if;
else
dbms_output.put_line('no such a track');
end if;
end if;
-- closing cursors
close c1;
close c2;
close c3;
close c4;
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
END;
Declare
prompt_user_id liked.user_id%Type :=4795;
prompt_track_id liked.track_id%Type :=199589;
Begin
proc_insert_liked(prompt_user_id, prompt_track_id);
end;
+0
另外 - 建议不要将对象创建和执行包括在同一个文件中。 –