[英]PL/SQL Procedure Error by dbms output function
I have the following task: "Write a Print Siblings procedure (p person) that has as input the name or ID of the person from the family tree scheme and, as a result, outputs the list of siblings." 我有以下任务:“编写一个打印兄弟姐妹过程(p个人),该过程具有来自家族树计划的该人的姓名或ID作为输入,并因此输出兄弟姐妹列表。”
Table Relations which contains the information of the successor(Nachfolger) and predecessor(Vorgänger) of a person. 表关系,包含一个人的后继者(Nachfolger)和前任者(Vorgänger)的信息。 Table Relations
表关系
My procedure is the following: 我的程序如下:
create or replace procedure PrintSiblings4(p_Person varchar2)
is
cursor c_geschwister is select nachfolger
from relations
where nachfolger != p_Person and vorgänger =
(select vorgänger from relations
Where nachfolger = p_Person and rownum = 1) ;
v_geschwister c_geschwister%rowtype;
begin
open c_geschwister;
loop
fetch c_geschwister into v_geschwister;
exit when c_geschwister%NOTFOUND;
dbms_output.put_line('geschwister' || v_geschwister);
end loop;
end;
I get the following error messages by the sqldeveloper if I compile the procedure: 如果我编译该过程,则sqldeveloper会收到以下错误消息:
Error (14,22): PLS-00306: Incorrect number or types of arguments in call to '||'
错误(14,22):PLS-00306:对“ ||”的调用中参数的数量或类型不正确
I can´t unterstand why it´s not working. 我无法理解为什么它不起作用。 I used an explicit cursor to handle the problem that i get more than 1 row, but its not working.
我使用了一个显式游标来处理我得到多于1行的问题,但行不通。
change: 更改:
dbms_output.put_line('geschwister' || v_geschwister);
to: 至:
dbms_output.put_line('geschwister' || v_geschwister.nachfolger);
Here a new (cleaner/compacter) version of your procedure. 这是您程序的新版本(清洁程序/压缩程序)。 We get here all columns of table relations:
我们在这里获得表关系的所有列:
create or replace procedure print_siblings4(p_person varchar2)
is
cursor c_geschwister is
select *
from relations
where nachfolger != p_person
and vorgänger =
(
select vorgänger
from relations
where nachfolger = p_person
and rownum = 1
)
;
begin
for r_geschwister in c_geschwister loop
dbms_output.put_line('geschwister' || v_geschwister.nachfolger);
end loop;
end;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.