CREATE OR REPLACE VIEW POINTS AS
DECLARE
avgDurationOurFault number(5);
avgDurationCustomersFault number(5);
avgDuration number(5);
BEGIN
(select ceil(avg(abs(total_time))) into avgDuration from inquiry);
select ceil(avg(total_duration)) into avgDurationOurFault
from
(
select customer_no, sum(abs(total_time)) total_duration
from inquiry
where cat_id in ('C900', 'C901', 'C902', 'C905', 'C907', 'C908', 'C909')
GROUP BY customer_no);
select ceil(avg(total_duration)) into avgDurationCustomersFault
from
(
select customer_no, sum(abs(total_time)) total_duration
from inquiry
where cat_id in ('C903','C904', 'C906')
group by customer_no);
select t1.customer_no, t1.callPoints, t1.durationPoints, t2.catgPoints,
t1.callPoints+t1.durationPoints+t2.catgPoints as totalPoints
from
(
select customer_no, count(inquiry_id)*avgDuration callPoints , sum(abs(total_time)) durationPoints
from inquiry
group by customer_no
) t1
inner join (
select customer_no, sum(points) catgPoints
from
(
select customer_no,
case
when cat_id in ('C903','C904', 'C906')
then 0
when cat_id in ('C900', 'C901', 'C902', 'C905', 'C907', 'C908', 'C909')
then 2*avgDuration + abs(avgDurationCustomersFault - avgDurationOurFault)
else
0
end as points
from inquiry
)
group by customer_no
) t2
on t1.customer_no = t2.customer_no;
END;
/
--------------------错误如下---------------------------- ----------------------
从命令的第 1 行开始出错:CREATE OR REPLACE VIEW POINTS AS DECLARE avgDurationOurFault number(5) 命令行错误:1 列:32 错误报告:SQL 错误:ORA-00928:缺少 SELECT 关键字 00928。00000 -“缺少 SELECT 关键字" *原因:
*措施:从命令中的第 4 行开始出错:avgDurationCustomersFault number(5) 错误报告:未知命令
从命令中的第 5 行开始出错:avgDuration number(5) 错误报告:未知命令
从命令中的第 7 行开始出错:
BEGIN
(select ceil(avg(abs(total_time))) into avgDuration from inquiry);
select ceil(avg(total_duration)) into avgDurationOurFault
from
(
select customer_no, sum(abs(total_time)) total_duration
from inquiry
where cat_id in ('C900', 'C901', 'C902', 'C905', 'C907', 'C908', 'C909')
GROUP BY customer_no);
select ceil(avg(total_duration)) into avgDurationCustomersFault
from
(
select customer_no, sum(abs(total_time)) total_duration
from inquiry
where cat_id in ('C903','C904', 'C906')
group by customer_no);
select t1.customer_no, t1.callPoints, t1.durationPoints, t2.catgPoints,
t1.callPoints+t1.durationPoints+t2.catgPoints as totalPoints
from
(
select customer_no, count(inquiry_id)*avgDuration callPoints , sum(abs(total_time)) durationPoints
from inquiry
group by customer_no
) t1
inner join (
select customer_no, sum(points) catgPoints
from
(
select customer_no,
case
when cat_id in ('C903','C904', 'C906')
then 0
when cat_id in ('C900', 'C901', 'C902', 'C905', 'C907', 'C908', 'C909')
then 2*avgDuration + abs(avgDurationCustomersFault - avgDurationOurFault)
else
0
end as points
from inquiry
)
group by customer_no
) t2
on t1.customer_no = t2.customer_no;
结尾;
错误报告:ORA-06550:第 3 行,第 2 列:PLS-00103:在预期以下情况之一时遇到符号“(”:
begin case declare exit for goto if loop mod null pragma raise return select update while with << close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe 符号“update”被替换为“(”继续。ORA -06550:第 3 行,第 37 列:PLS-00103:在预期以下情况之一时遇到符号“INTO”:
. ( , * % & - + / at mod rem as from || The symbol ". was inserted before "I ORA-06550: line 3, column 67: PLS-00103: Encountered the symbol ";" 当期望以下之一时:
设置 ORA-06550:第 30 行,第 3 列:PLS-00103:在预期以下情况之一时遇到符号“INNER”:
, ; 对于有相交减去顺序开始联合的组,
连接 06550。00000 - “行 %s,列 %s:\n%s” *原因:通常是 PL/SQL 编译错误。*行动: