I have a problem with procedures in PL/SQL. I have a public procedure declared in a package and I want to call another procedure(private) inside the first one.
PROCEDURE show_notesforstudent (number_id IN number) as
...
DBMS_OUTPUT.PUT_LINE('The notes for the student with number_id X are: '|| Y);
DBMS_OUTPUT.PUT_LINE('here is the call for the private procedure');
erase_student(number_id);
END;
This code is a general example, my code is bigger and I can't put it all here. Here is only the main idea. For this call I face this error: "Error(31,5): PLS-00313: 'erase_student' not declared in this scope".
The implementation of erase_student procedure is:
PROCEDURE erase_student(n_id students.number_id%type) AS
student_inexistent EXCEPTION;
PRAGMA EXCEPTION_INIT(student_inexistent, -20002);
counter integer;
BEGIN
SELECT COUNT(nmber_id) INTO counter FROM studens where number_id = n_id;
IF counter = 0 THEN
raise student_inexistent;
END IF;
DELETE FROM students WHERE number_id = n_id;
EXCEPTION
WHEN student_inexistent THEN
raise_application_error (-20002, 'Student with number_id' || n_id || ' doesn't exists in database');
END stergere_student;`
erase_studentprocedure before theshow_notesforstudentor use a forward declaration of theerase_student's header at the start of the procedure. - MT0erase_studentdoesn't exist because of the syntax errors inerase_students. It appears that the table name in theSELECT COUNT(*)...should bestudentsrather thanstudens. Also, the name of the procedure (erase_student) doesn't match the name on theEND stergere_studentstatement. Possibly an issue when translating (from Romanian?). Also, in theRAISE_APPLICATION_ERRORcall, the apostrophe indoesn'tshould be doubled (doesn''t) so you get one apostrophe in the string literal. Best of luck. - Bob Jarvis - Reinstate Monica