這是我第一次運行PL SQL,因此我可能會犯一些愚蠢的錯誤。 我正在嘗試在Oracle Express Edition 11g中編寫一個過程。我遇到了與過程體中的WITH子句有關的錯誤。OracleEE 11g WITH子句導致錯誤過程無法編譯
每當我嘗試並運行它,我看到兩個錯誤。
Error report:
ORA-06550: line 14, column 50:
PL/SQL: ORA-00918: column ambiguously defined
ORA-06550: line 12, column 7:
PL/SQL: SQL Statement ignored
ORA-06550: line 29, column 3:
PLS-00306: wrong number or types of arguments in call to 'FIND_HIGH_AVG'
ORA-06550: line 29, column 3:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
該程序的代碼如下。
DECLARE
myTerm courses.term%type;
myLine courses.lineno%type;
procedure find_high_avg (term IN courses.term%type,
line IN courses.lineno%type,
s_fname OUT students.fname%type,
s_lname OUT students.lname%type,
s_sid OUT students.side%type,
s_avg OUT number) is
begin
WITH grades as (select * from components co --line 12 here
join scores sc on co.term = sc.term and co.lineno = sc.lineno and CO.COMPNAME = SC.COMPNAME
where sc.lineno = line and sc.term = term) --line 14 here
select *
into s_fname, s_lname, s_sid, s_avg
from (
select s.fname, s.lname, s.sid, round(sum(points/maxpoints * weight),0) as AV
from grades, students
join students s on grades.sid = s.sid
group by s.sid, s.fname, s.lname
order by AV)
where rownum = 1;
end;
BEGIN
myTerm:='F12';
myLine:='1031';
find_high_avg(myTerm, myLine); --line 29 here
END;
我做了這個改變,但是我遇到了編譯器仍然會遇到的問題。更新了主要問題以反映這一點。 – tyh 2012-02-21 22:50:08
@timyh - 更新了我的答案,還有一些問題。 – 2012-02-22 02:14:56
非常感謝您提供了非常好的詳細解答,並且我對這一切如何運作有了更好的理解。 – tyh 2012-02-23 03:19:24