2014-10-08 2 views
-1

모든 행을 GAMETABLE에 표시하고 행 중 하나를 HOWTOPLAY에 표시하려고합니다. 내가 주위에 봤지만 두 개의 테이블에서 하나의 커서로 열을로드하고 그들을 표시하는 방법을 알아낼 수 없습니다.다른 테이블의 열을 커서로로드하고 표시하려면 어떻게합니까?

오라클 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: 
+0

어떤 오류가 발생 했나요? 오류가 발생한 행은 무엇입니까? 아니면 당신이 원하는 행동이 아니라는 것을 당신은 어떤 행동으로 봅니까? –

답변

0

당신은 ',' v_howtoplayinfo) 사이 CONCAT 연산자를 잊어 버렸습니다.

',' || v_howtoplayinfo)이어야합니다.

그런데 긴 줄을 끊을 수 있습니다. 그렇게하면 오른쪽으로 스크롤하지 않고도 읽을 수 있습니다. 그런 오류를 직접 발견 할 가능성이 큽니다.

+0

와우 .... 감사합니다! –

관련 문제