PL / SQL过程不起作用。请帮忙?

时间:2014-10-22 15:38:00

标签: sql oracle stored-procedures plsql

这是我的程序,编译很好我试图获得发布日期和持续时间,当我进入电影标题:

create or replace PROCEDURE get_films
(fname IN film.title%type,
r_date OUT film.release_date%type,
dur OUT film.f_duration%type) AS
BEGIN
SELECT release_date, f_duration into
r_date, dur
FROM FILM
WHERE title = fname;
EXCEPTION
WHEN NO_DATA_FOUND THEN
r_date:='';dur:='';
END get_films;

当我打电话给它时,我得到了错误:

set serveroutput on
DECLARE
ftit FILM.TITLE%type:=&Enter_Film_Title;
frdate film.release_date%type;
fdur film.f_duration%type;
BEGIN
GET_FILMS(ftit, frdat, fdur);
DBMS_OUTPUT.PUT_LINE('Title         Release_date     F_Duration');
DBMS_OUTPUT.PUT_LINE(ftit||'        '||frdate||'            '||fdur);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLCODE||SQLERRM);
END;

错误:

old:EXECUTE GET_FILMS(&Enter_Title)
new:EXECUTE GET_FILMS(Interstellar)

Error starting at line : 17 in command -
EXECUTE GET_FILMS(&Enter_Title)
Error report -
ORA-06550: line 1, column 17:
PLS-00201: identifier 'INTERSTELLAR' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

1 个答案:

答案 0 :(得分:1)

INTERSTELLAR被视为变量而不是字符串值。您需要将值放在单引号中:

ftit FILM.TITLE%type:='&Enter_Film_Title';