0
好吧,我正在使用存儲過程做家庭作業。Oracle SQL存儲過程光標打印
本質上,我只是試圖使用存儲過程來運行查詢,然後打印結果。
這是我到目前爲止。
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
任何幫助將不勝感激。
太棒了,這是很好的建議。我想我必須逃避NAME,因爲它是一個關鍵字,但它似乎工作得很好。感謝您的幫助。 – mingle 2013-05-07 16:28:53