存储过程编译错误
有人可以帮我解决这个问题,这是我运行此脚本时收到的错误消息
第 1 行出现错误: ORA-00979: 不是 GROUP BY 表达式 ORA-06321: 在“s3398293.P2”,第 7 行 ORA-06321: 在“s3398293.P2”,第 18 行 ORA-06321: 在第 1 行
代码:
create or replace
PROCEDURE p2(x NUMBER )
as
staff_info staff.bno%TYPE;
address_info varchar2(20);
CURSOR c1 IS
SELECT staff.bno ,
branch.street || ' ' || branch.suburb || ' ' || branch.postcode
FROM deal , staff, contact , property , branch
where staff.peid = contact.peid
and contact.pno = property.pno
and property.pno = deal.pno
and staff.peid = branch.peid
group by staff.bno
HAVING x > sum(deal.price);
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO staff_info,address_info ;
EXIT WHEN c1%notfound;
dbms_output.put_line('BRANCH# '||' '||'ADDRESS');
dbms_output.put_line(staff_info ||' '|| address_info);
END LOOP;
close c1;
END;
/
有人可以告诉我更多关于 GROUP BY EXPRESSION 的信息吗? ?
Can Someone help me on this , this is the error message I am getting when I run this script
ERROR at line 1: ORA-00979: not a GROUP BY expression ORA-06321: at "s3398293.P2", line 7 ORA-06321: at "s3398293.P2", line 18 ORA-06321: at line 1
The code:
create or replace
PROCEDURE p2(x NUMBER )
as
staff_info staff.bno%TYPE;
address_info varchar2(20);
CURSOR c1 IS
SELECT staff.bno ,
branch.street || ' ' || branch.suburb || ' ' || branch.postcode
FROM deal , staff, contact , property , branch
where staff.peid = contact.peid
and contact.pno = property.pno
and property.pno = deal.pno
and staff.peid = branch.peid
group by staff.bno
HAVING x > sum(deal.price);
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO staff_info,address_info ;
EXIT WHEN c1%notfound;
dbms_output.put_line('BRANCH# '||' '||'ADDRESS');
dbms_output.put_line(staff_info ||' '|| address_info);
END LOOP;
close c1;
END;
/
Can Someone tell me more about GROUP BY EXPRESSION! ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
按如下方式更改游标语句(编辑 2!):
编辑 - 根据注释:
您的
LOOP
应如下所示:change the cursor statement as follows (EDIT 2!):
EDIT - as per comments:
Your
LOOP
should look as follows: