PLS-00103:遇到符号&#34;;&#34;在需要以下其中一项时:<标识符=“”> <a d=""

时间:2017-12-08 05:18:45

标签: sql database oracle

="" I am trying to change the value of "TOTAL_TM_R_PT" where all the times a certain player shows up.

create or replace PROCEDURE CalculatePlayerTMPoints(Player IN NUMBER,PointNum IN NUMBER) 
DECLARE PtValue INT;
UserNM TABLE; 
BEGIN
    SELECT POINT_VALUE INTO PtValue FROM POINTS WHERE POINTS.POINT_ID = PointNum;     
    SELECT ACCT_USERNAME INTO UserNM FROM ROSTERS WHERE ROSTERS.PLAYER_ID = Player;
    for i in 1..UserNM.count
    loop
        UPDATE TEAM_MANAGER_POINTS
        SET TOTAL_TM_R_PT = TOTAL_TM_R_PT + PtValue 
        WHERE TEAM_MANAGER_POINTS.ACCT_USERNAME = UserNM;
    End loop;
END;

This is my error:

Error(3,1): PLS-00103: Encountered the symbol "DECLARE" when expecting one of  
the following:     ; is with authid as cluster order using external    
deterministic parallel_enable pipelined result_cache    accessible 

Any ideas?

1 个答案:

答案 0 :(得分:1)

您需要定义集合类型并使用BULK COLLECT INTO将查询结果存储在集合中。 AS关键字,使用Declare无效。

create or replace PROCEDURE CalculatePlayerTMPoints(Player IN NUMBER,PointNum IN NUMBER) AS
PtValue INT;
TYPE usertype IS TABLE OF ROSTERS.ACCT_USERNAME%TYPE;
UserNM usertype ; 
BEGIN
    SELECT POINT_VALUE INTO PtValue FROM POINTS WHERE POINTS.POINT_ID = PointNum;     
    SELECT ACCT_USERNAME BULK COLLECT INTO UserNM FROM ROSTERS WHERE ROSTERS.PLAYER_ID = Player;
    for i in 1..UserNM.count
    loop
        UPDATE TEAM_MANAGER_POINTS
        SET TOTAL_TM_R_PT = TOTAL_TM_R_PT + PtValue 
        WHERE  ACCT_USERNAME = UserNM(i);
    End loop;
END;