-1
我想顯示GAMETABLE中的所有行,並在HOWTOPLAY中顯示其中一行。我搜索了一遍,但無法弄清楚如何從2個表中加載列到一個光標並顯示它們。如何將不同表格中的列加載到光標並顯示它們?
使用oracle 11g。
這是我的存儲過程的代碼:
PROCEDURE GetLotteryGame (lg_id IN number, lg_ref OUT lotg_ref_cursor) IS
BEGIN
OPEN lg_ref FOR
SELECT a.GAMEDETAILSID,a.GAMENAME,a.GAMECOST,a.GAMEDESCRIPTION,a.WHERETOPLAY,b.HOWTOPLAYINFO
FROM GAMEDETAILS a
INNER JOIN HOWTOPLAY b
on b.GAMEDETAILSID = a.GAMEDETAILSID
WHERE a.GAMEDETAILSID >= lg_id;
END GetLotteryGame;
這是我的電話程序的代碼:
SET SERVEROUTPUT ON size 100000
DECLARE
v_cursor LOTTERYGAMEPKG.lotg_ref_cursor;
v_gamedetailsid GAMEDETAILS.gamedetailsID%type;
v_gamename GAMEDETAILS.gamename%type;
v_gamecost GAMEDETAILS.gamecost%type;
v_gamedescription GAMEDETAILS.gamedescription%type;
v_wheretoplay GAMEDETAILS.wheretoplay%type;
v_howtoplayinfo HOWTOPLAY.howtoplayinfo%type;
BEGIN
LOTTERYGAMEPKG.GetLotteryGame(lg_id => 1,
lg_ref => v_cursor);
LOOP
FETCH v_cursor
INTO v_gamedetailsID, v_gamename, v_gamecost, v_gamedescription, v_wheretoplay, v_howtoplayinfo;
EXIT WHEN v_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(v_gamedetailsID || ',' || v_gamename || ',' || v_gamecost || ',' || v_gamedescription || ',' || v_wheretoplay || ',' v_howtoplayinfo);
END LOOP;
CLOSE v_cursor;
END;
錯誤報告:
Error report -
ORA-06550: line 17, column 143:
PLS-00103: Encountered the symbol "V_HOWTOPLAYINFO" when expecting one of the following:
) , * & = - + </> at in is mod remainder not rem =>
<an exponent (**)> <> or != or ~= >= <= <> and or like like2
like4 likec as between from using || member submultiset
The symbol "," was substituted for "V_HOWTOPLAYINFO" to continue.
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
你會得到什麼錯誤?什麼是錯誤?或者你看到哪種行爲不是你想要的? – 2014-10-08 17:40:46