6

I'm getting compile errors with this code using sqlplus.

My errors are:

Warning: Procedure created with compilation errors.

BEGIN point_triangle; END;

Error at line 1: ORA-06550: Line 1, column 7:
PLS-00905: object POINT_TRIANGLE is invalid
ORA-06550: line 1, column 7:
PL/SQL Statement ignored

Whenever I type show errors, it tells me there are no errors.

Here is the code.

create or replace procedure point_triangle
AS
A VARCHAR2(30);
B VARCHAR2(30);
C INT;
BEGIN
FOR thisteam in (select P.FIRSTNAME into A from PLAYERREGULARSEASON P where P.TEAM = 'IND' group by P.FIRSTNAME, P.LASTNAME order by SUM(P.PTS) DESC)
                (select P.LASTNAME into B from PLAYERREGULARSEASON P where P.TEAM = 'IND' group by P.FIRSTNAME, P.LASTNAME order by SUM(P.PTS) DESC)
                (select SUM(P.PTS) into C from PLAYERREGULARSEASON P where P.TEAM = 'IND' group by P.FIRSTNAME, P.LASTNAME order by SUM(P.PTS) DESC);
LOOP
    dbms_output.put_line(A|| ' ' || B || ':' || C);
END LOOP;

END;
/

it is suppose to put all the players into A and B with their points of their career on that team into the C. I know the queries work, just not in the procedure.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user3002669
  • 63
  • 1
  • 2
  • 4

3 Answers3

3
create or replace procedure point_triangle
AS
BEGIN
FOR thisteam in (select FIRSTNAME,LASTNAME,SUM(PTS)  from PLAYERREGULARSEASON  where TEAM    = 'IND' group by FIRSTNAME, LASTNAME order by SUM(PTS) DESC)

LOOP
dbms_output.put_line(thisteam.FIRSTNAME|| ' ' || thisteam.LASTNAME || ':' || thisteam.PTS);
END LOOP;

END;
/
The Hungry Dictator
  • 3,444
  • 5
  • 37
  • 53
  • Would there be any way I could print out two different FIRSTNAMES, LASTNAME, and PTS in the same line? Like move through the list in the same iteration of the loop. – user3002669 Nov 19 '13 at 20:41
0

Could you try this one:

create or replace 
procedure point_triangle
IS
BEGIN
  FOR thisteam in (select P.FIRSTNAME,P.LASTNAME, SUM(P.PTS) S from PLAYERREGULARSEASON P  where P.TEAM = 'IND'  group by P.FIRSTNAME, P.LASTNAME order by SUM(P.PTS) DESC)
  LOOP
    dbms_output.put_line(thisteam.FIRSTNAME|| ' ' || thisteam.LASTNAME  || ':' || thisteam.S);
  END LOOP;

END;
Sergey N Lukin
  • 575
  • 2
  • 16
0

There is a semi colon at the end of the query after the closing braces, remove it and it will work:

FOR thisteam in (select P.FIRSTNAME into A from PLAYERREGULARSEASON P where P.TEAM = 'IND' group by P.FIRSTNAME, P.LASTNAME order by SUM(P.PTS) DESC)
            (select P.LASTNAME into B from PLAYERREGULARSEASON P where P.TEAM = 'IND' group by P.FIRSTNAME, P.LASTNAME order by SUM(P.PTS) DESC)
            (select SUM(P.PTS) into C from PLAYERREGULARSEASON P where P.TEAM = 'IND' group by P.FIRSTNAME, P.LASTNAME order by SUM(P.PTS) DESC)**;**