我正在尝试将我的MySQL项目转换为PL / SQL,以实现作为顶级应用程序。我有关于转换存储过程的问题。当我在MySQL中使用它时,它正在工作,但它在PL / SQL中出错。我已阅读有关PL / SQL语法的内容,我认为我已完成必要的更改以将存储过程转换为PL / SQL格式。
我的代码如下:
create or replace PROCEDURE findSuitableRoom
(
varBuilding_id IN NUMBER,
varLecture_block_id IN NUMBER,
varWeek_of_the_day IN NUMBER
) AS
BEGIN
SELECT A.room_id
FROM
(
SELECT room_id, room_number, r.building_id FROM building INNER JOIN
(SELECT room.room_id, room_number, ruilding_id FROM room INNER JOIN room_building_location
ON room.room_id=room_building_location.room_id) AS R
ON building.building_id=r.building_id WHERE r.building_id=varBuilding_id
) AS A
LEFT JOIN
(
SELECT room_id FROM timetable WHERE timetable.lecture_block_id=varLecture_block_id AND timetable.week_of_the_day=varWeek_of_the_day
) AS B
ON A.room_id=B.room_id WHERE B.room_id IS NULL;
END;
答案 0 :(得分:0)
我认为Apex是一个Oracle产品,您应该能够将MySQL程序转换为PL / SQL程序并在Apex代码中使用它。您需要返回REF CURSOR,如下面的转换示例所示。以下是Oracle社区网站上帖子的link,其中包含与Apex相关的其他示例代码。您需要向下滚动到页面所在的位置http://apex.oracle.com/pls/apex/f?p=34598:1
,您将看到其下方的代码
您应该能够使用此处的示例代码和下面转换的过程来完成转换。
CREATE OR REPLACE PACKAGE sample_ref_cursor_pkg AS
TYPE sample_ref_cursor IS REF CURSOR;
END Types;
/
create or replace PROCEDURE findSuitableRoom
(
varBuilding_id IN NUMBER,
varLecture_block_id IN NUMBER,
varWeek_of_the_day IN NUMBER
,out_cursor OUT sample_ref_cursor_pkg.sample_ref_cursor
) AS
BEGIN
OPEN out_cursor
FOR
SELECT A.room_id
FROM
(
SELECT room_id, room_number, r.building_id FROM building INNER JOIN
(SELECT room.room_id, room_number, ruilding_id FROM room INNER JOIN room_building_location
ON room.room_id=room_building_location.room_id) AS R
ON building.building_id=r.building_id WHERE r.building_id=varBuilding_id
) AS A
LEFT JOIN
(
SELECT room_id FROM timetable WHERE timetable.lecture_block_id=varLecture_block_id AND timetable.week_of_the_day=varWeek_of_the_day
) AS B
ON A.room_id=B.room_id WHERE B.room_id IS NULL;
END;
希望这有帮助。