好的,所以我正在使用存储过程进行家庭作业。
本质上,我只是想使用存储过程来运行查询然后打印结果。
这是我到目前为止所拥有的。
create or replace procedure movie_actors (mtitle varchars)as
DECLARE
CURSOR c1 is SELECT "NAME",GENDER,ADDRESS FROM MOVIESTAR WHERE "NAME" in(
SELECT STARNAME FROM STARSIN WHERE MOVIETITLE=mtitle);
actor_name MOVIESTAR.NAME%TYPE;
actor_gender MOVIESTAR.NAME%TYPE;
actor_address MOVIESTAR.ADDRESS%TYPE;
BEGIN
LOOP
   FETCH c1 INTO actor_name;
   FETCH c1 INTO actor_gender;
   FETCH c1 INTO actor_address;
   EXIT WHEN c1%NOTFOUND;
   DBMS_OUTPUT.PUT_LINE(mtitle ||', '||actor_name||': '||actor_gender||', '||actor_address); 
END LOOP;
END;
我是数据库和存储过程的新手。我不确定我是否真的是最好的方法。
这应该很简单,我不确定我做错了什么。
这是我得到的编译器错误。
Error(2,1): PLS-00103: Encountered the symbol "DECLARE" when expecting one of the   
following:     begin function pragma procedure subtype type <an identifier>    <a   
double-quoted delimited-identifier> current cursor delete    exists prior external 
language The symbol "begin" was substituted for "DECLARE" to continue. 
Error(16,4): PLS-00103: Encountered the symbol "end-of-file" when expecting one of the
following:     ( begin case declare end exception exit for goto if loop mod    
null pragma raise return select update while with    <an identifier> <a double-quoted 
delimited-identifier>    <a bind variable> << continue close current delete fetch lock 
insert open rollback savepoint set sql execute commit forall    merge pipe purge 
任何帮助将不胜感激。