【问题标题】:warning: procedure created with compilation errors sql3警告:使用编译错误 sql3 创建的过程
【发布时间】:2017-05-08 14:01:47
【问题描述】:

我创建了两个表,album 和 personnage,第三个包含引用但它返回此错误:

警告:过程创建时出现编译错误。

有什么问题。?怎么解决。?

 CREATE OR REPLACE PROCEDURE TT1_AJOUTE_PERSON_DANS_ALBUM(pnump in number , pnuma in number) 
--paramètres à préciser
 IS
 v_pers number;
 v_alb number;

 BEGIN
 select count(a.numa) into v_alb
 from tt1_album a
where (a.numa=pnuma);

if(v_alb=0) then
dbms_output.put_line('album introuvable');
end if;

select count(p.nump) into v_pers
from tt1_peronnage p
where (p.nump=pnump);

if(v_pers=0) then
dbms_output.put_line('personnage introuvable');
end if;

 if(v_pers=1 and v_alb=1 ) then
insert into tt1_abl_pers values((select ref(a) from tt1_album a 
where(a.numa=pnuma));
(select ref(p) from tt1_personnage p where(p.nump=pnump)));
end if;

END ;
 /

当我运行命令显示错误时,它返回

【问题讨论】:

  • 你定义函数ref()了吗?
  • 是的,定义不正确
  • 在 SQL*Plus 中运行 SHOW ERRORS 命令以显示错误。
  • 在最后的 'END IF' 之前有一个无效行。看不出它的意图是什么。看起来它应该是插入的一部分。
  • 请看它提到的行号。你有一个分号而不是插入的逗号。正如消息所暗示的那样。

标签: sql oracle stored-procedures


【解决方案1】:

错误是由您的这段代码引起的:

插入 tt1_abl_pers 值((从 tt1_album a 中选择 ref(a) 其中(a.numa=pnuma)); (从 tt1_personnage p 中选择 ref(p) 其中(p.nump=pnump)));

我假设您要将函数结果 [ref(a) 和 ref(p)] 的值插入到表 tt1_abl_pers:

INSERT INTO tt1_abl_pers
(ref)
SELECT ref(a) FROM tt1_album a WHERE(a.numa=pnuma)
UNION ALL
SELECT ref(p ) FROM tt1_personnage p WHERE(p.nump=pnump);

【讨论】:

    猜你喜欢
    • 2012-01-20
    • 1970-01-01
    • 2013-06-13
    • 2014-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-08
    • 1970-01-01
    相关资源
    最近更新 更多