-1
我試圖運行此代碼,但它給了我一個「THEN」中的錯誤,我已經逐行檢查了所有代碼,錯誤是在if語句中,但我仔細檢查了它。PLS-00103:在遇到以下其中一項時遇到符號「THEN」
我想比較事故發生的時間,所以我可以將救護車送到首次發生的事故。我會感激你的幫助
`create or replace function get_loc return location is
max NUMBER;
CURSOR accident_records IS
SELECT * FROM NEW_ACCIDENT;
accidentRec NEW_ACCIDENT_TYPE := NEW_ACCIDENT_TYPE (NULL,NULL,NULL,NULL);
ac_loc LOCATION := LOCATION (NULL,NULL);
type New_accident_rec_type is record
(
id number,
loc location,
TIME NUMBER,
SITUATION varchar2(60)
);
new_accident_rec New_accident_rec_type;
BEGIN
max:=0;
OPEN accident_records;
LOOP FETCH accident_records INTO new_accident_rec;
EXIT WHEN accident_records%NOTFOUND;
IF new_accident_rec.situation='not handled' then
IF new_accident_rec.time>max THEN
max:=new_accident_rec.time;
accidentRec.time:=new_accident_rec.time;
ac_loc:=new_accident_rec.loc;
END IF;
IF new_accident_rec.time<max THEN
ac_loc:=NULL;
END IF;
END IF;
END LOOP;
CLOSE accident_records;
dbms_output.put_line ('The time of Accident is: '||accidentRec.time || 'The location of the accident is: ' ||ac_loc);
RETURN ac_loc;
END;`
謝謝你,我想通了:) –