Ajax
Ajax

Reputation: 150

how to solve Warning: Function created with compilation errors

Trying to develop a PL/SQL functions to print total credits registered by the particular student and read the student id from the user.

this is the code

 CREATE OR REPLACE FUNCTION totalcredit (stuid IN NUMBER)  RETURN number
IS
total number(100) := 0;
BEGIN
SELECT sum(b.credit) INTO total FROM student a INNER JOIN student_course c ON a.studid = c.studid INNER JOIN course b ON c.courseid = b.courseid WHERE a.studid = stuid;
RETURN total;
END;
/

and this is the table details

Upvotes: 0

Views: 618

Answers (1)

You can obtain the actual errors by reading them from one of the *_ERRORS views, e.g. USER_ERRORS for objects in the schema of the logged-on user, ALL_ERRORS for errors associated with objects which can be read by the current user, or DBA_ERRORS for errors associated with all objects in the database.

You can read them by using a SELECT such as:

SELECT *
  FROM USER_ERRORS
  WHERE NAME = 'TOTALCREDIT'

Keep in mind that Oracle uses UPPER-CASE for all schema objects unless they are explicitly quoted, so you need to specify the UPPER-CASE version of the name when querying these views.

Documentation here


In the case of your function, it looks to me like the problem is the line which reads

total  number(100) := 0;

Oracle only supports precision of up to 38 digits. I suggest you change this to

total  number := 0;

and see how that works for you.

Best of luck.

Upvotes: 2

Related Questions