In an earlier post, I had some problems with compiling the procedure below (which is supposed to update the attribute profile based on how many tasks an author has written) – now, it does compile (with warnings though) and when I try to execute it, it fails. I cannot figure out why. I’m using ExecuteQuery to connect to a remote Oracle database. The tables involved in the procedure are:
Task(TaskID, ..., AuthorID)
Author(AuthorID, profile, name, ...)
Here is the procedure (my specific questions follow below):
ALTER SESSION SET PLSQL_WARNINGS='ENABLE:ALL';
CREATE OR REPLACE PROCEDURE profil_stufe
IS
CURSOR c1 IS SELECT AuthorID, COUNT(AuthorID) as Total FROM Task
GROUP BY AuthorID;
result INTEGER c1%ROWTYPE;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO result;
EXIT WHEN c1%NOTFOUND;
IF(result.Total = 2 OR result.Total = 3) THEN
UPDATE Author SET profile = 'Advanced' WHERE AuthorID = result.AuthorID;
END IF;
IF(result.Total >= 4) THEN
UPDATE Author SET profile = 'proficient' WHERE AuthorID = result.AuthorID;
END IF;
END LOOP;
CLOSE c1;
END;
My questions:
-
First of all, I am not able to retrieve the warnings produced when compiling the procedure. I tried queries like
select plsql_warnings from user_plsql_object_settings ps where ps.name = 'profil_stufe';orselect * from user_errors ur where ur.name = 'profil_stufe';but neither deliver any result, even though the procedure does compile with warnings. -
When I perform
execute profil_stufeI get an error
ORA-06550: Row 1, Column 16: PLS-00905: object CS261_20.PROFIL_STUFE
is invalid ORA-06550: Row 1, Column 7: PL/SQL: Statement ignored
Can somebody help me out? I know, that I could avoid creating a procedure and implement the same functionality otherwise. But it seems like I am missing some basic concepts of PL/SQL and I would really like to get to understand them … So, thanks for your help!
why do you have the variable declaration as :
result INTEGER c1%ROWTYPE;It should be
result c1%ROWTYPE;