我在创建
的程序上遇到两个错误错误是:
这是我的代码,给出错误的行有对它们的评论:
CREATE OR REPLACE PROCEDURE get_route_times(route IN VARCHAR2, day IN VARCHAR2,
refcursor OUT sys_refcursor)
AS
cursorSend sys_refcursor;
BEGIN
OPEN cursorSend FOR
SELECT RS.ROUTE_NO, RS.DIRECTION, RS.STOP_NAME, RS.JOURNEY_TIME, -- (ERROR 1 HERE)
CASE
WHEN lower(day)='sat' THEN to_char(trunc(sysdate-1/24, 'HH')+RS.JOURNEY_TIME/1440, 'HH24:MI')
WHEN lower(day)='sun' THEN to_char(trunc(sysdate-1/24, 'HH')+RS.JOURNEY_TIME/1440, 'HH24:MI')
ELSE to_char(trunc(sysdate-1/24, 'HH')+RS.JOURNEY_TIME/1440, 'HH24:MI')
END AS "1",
CASE
WHEN lower(day)='sat' THEN to_char(trunc(sysdate-1/24, 'HH') + sat.Frequency + RS.JOURNEY_TIME/1440, 'HH24:MI')
WHEN lower(day)='sun' THEN to_char(trunc(sysdate-1/24, 'HH') + sun.Frequency + RS.JOURNEY_TIME/1440, 'HH24:MI')
ELSE to_char(trunc(sysdate-1/24, 'HH')+week.Frequency + RS.JOURNEY_TIME/1440, 'HH24:MI')
END AS "2",
CASE
WHEN lower(day)='sat' THEN to_char(trunc(sysdate-1/24, 'HH') + sat.Frequency*2 + RS.JOURNEY_TIME/1440, 'HH24:MI')
WHEN lower(day)='sun' THEN to_char(trunc(sysdate-1/24, 'HH') + sun.Frequency*2 + RS.JOURNEY_TIME/1440, 'HH24:MI')
ELSE to_char(trunc(sysdate-1/24, 'HH')+week.Frequency*2 + RS.JOURNEY_TIME/1440, 'HH24:MI')
END AS "3",
CASE
WHEN lower(day)='sat' THEN to_char(trunc(sysdate-1/24, 'HH') + sat.Frequency*3 + RS.JOURNEY_TIME/1440, 'HH24:MI')
WHEN lower(day)='sun' THEN to_char(trunc(sysdate-1/24, 'HH') + sun.Frequency*3 + RS.JOURNEY_TIME/1440, 'HH24:MI') -- ERROR 2 on this line
ELSE to_char(trunc(sysdate-1/24, 'HH')+week.Frequency*3 + RS.JOURNEY_TIME/1440, 'HH24:MI')
END AS "4"
FROM BBT_ROUTESTOP RS
INNER JOIN SATFREQ sat
ON RS.ROUTE_NO = sat.ROUTE
INNER JOIN SUNFREQ sun
ON RS.ROUTE_NO = sun.ROUTE
INNER JOIN WEEKFREQ week
ON RS.ROUTE_NO = week.ROUTE
WHERE lower(RS.ROUTE_NO)=lower(route)
Order by RS.DIRECTION ASC;
refcursor := cursorSend;
END;
我已经看了好几个小时了,对不起,如果这没有意义,我希望你能提供帮助!
由于
答案 0 :(得分:0)
您有route
作为存储过程的参数,它也是SATFREQ
,SUNFREQ
和WEEKFREQ
表中的一列,查询无法解决在哪一行:WHERE lower(RS.ROUTE_NO)=lower(route)
。
重命名参数:
CREATE OR REPLACE PROCEDURE get_route_times(
in_route IN VARCHAR2,
in_day IN VARCHAR2,
out_cursor OUT sys_refcursor)
AS
BEGIN
OPEN out_cursor FOR
SELECT RS.ROUTE_NO,
RS.DIRECTION,
RS.STOP_NAME,
RS.JOURNEY_TIME,
to_char(
trunc(sysdate-1/24, 'HH') + RS.JOURNEY_TIME/1440,
'HH24:MI'
) AS "1",
to_char(
trunc(sysdate-1/24, 'HH')
+ RS.JOURNEY_TIME/1440
+ 1 * CASE lower(in_day) WHEN 'sat' THEN Sat.FREQUENCY
WHEN 'sat' THEN Sun.FREQUENCY
ELSE Week.FREQUENCY END,
'HH24:MI'
) AS "2",
to_char(
trunc(sysdate-1/24, 'HH')
+ RS.JOURNEY_TIME/1440
+ 2 * CASE lower(in_day) WHEN 'sat' THEN Sat.FREQUENCY
WHEN 'sat' THEN Sun.FREQUENCY
ELSE Week.FREQUENCY END,
'HH24:MI'
) AS "3",
to_char(
trunc(sysdate-1/24, 'HH')
+ RS.JOURNEY_TIME/1440
+ 3 * CASE lower(in_day) WHEN 'sat' THEN Sat.FREQUENCY
WHEN 'sat' THEN Sun.FREQUENCY
ELSE Week.FREQUENCY END,
'HH24:MI'
) AS "4"
FROM BBT_ROUTESTOP RS
INNER JOIN SATFREQ sat
ON RS.ROUTE_NO = sat.ROUTE
INNER JOIN SUNFREQ sun
ON RS.ROUTE_NO = sun.ROUTE
INNER JOIN WEEKFREQ week
ON RS.ROUTE_NO = week.ROUTE
WHERE lower(RS.ROUTE_NO) = lower( in_route )
ORDER BY RS.DIRECTION ASC;
END;