如何解决警告:函数创建时出现编译错误
尝试开发PL/SQL函数以打印特定学生注册的总学分并从用户那里读取学生ID.
Trying to develop a PL/SQL functions to print total credits registered by the particular student and read the student id from the user.
这是代码
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;
/
和这是表格的详细信息
您可以通过从* _ERRORS视图之一读取它们来获取实际错误,例如USER_ERRORS表示登录用户的模式中的对象,ALL_ERRORS表示与当前用户可以读取的对象相关的错误,DBA_ERRORS表示与数据库中所有对象相关的错误.
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.
您可以使用SELECT之类的内容来阅读它们,
You can read them by using a SELECT such as:
SELECT *
FROM USER_ERRORS
WHERE NAME = 'TOTALCREDIT'
请记住,除非对所有架构对象都使用UPPER-CASE,否则除非对其进行显式引用,所以在查询这些视图时,您需要指定名称的UPPER-CASE版本.
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.
就您的功能而言,在我看来问题出在读取的行上
In the case of your function, it looks to me like the problem is the line which reads
total number(100) := 0;
Oracle仅支持不超过38位的精度.我建议您将其更改为
Oracle only supports precision of up to 38 digits. I suggest you change this to
total number := 0;
看看它如何为您工作.
好运.