尝试创建一个基于 pl/sql 游标的函数以从 oracle 数据库返回详细信息。
相关表MEETING
具有以下列
MEETING_ID
:number(10) TIME
、:timestamp(4) TITLE
、:varchar(20)
CREATE OR REPLACE FUNCTION GetMeeting
(meetingnumber MEETING.MEETING_ID%TYPE)
RETURN VARCHAR
IS
CURSOR current_meeting(meetingnumber MEETING.MEETING_ID%TYPE)
IS
SELECT TITLE, TIME
FROM MEETING
WHERE MEETING_ID = meetingnumber;
r_meeting current_meeting%ROWTYPE;
BEGIN
OPEN current_meeting(meetingnumber);
FETCH current_meeting INTO r_meeting;
IF current_meeting%NOTFOUND THEN
r_meeting.TITLE := 'UNKNOWN APPOINTMENT';
END IF;
CLOSE current_meeting;
RETURN r_meeting.TITLE;
END;
SELECT GetMeeting (27) name
FROM MEETING;
该函数似乎可以编译 - 但是当调用时会抛出
ORA-06575: 包或函数 GETMEETING 处于无效状态