[英]calculate gpa oracle pl sql
我在pl / sql中是個菜鳥。 我正在嘗試使用pl sql計算gpa。 我創建了一個表,其中包含值的等級。
SSN CNO GRADE
--------------- -------- ----------
55555 cs101 1
55555 math101 4
55555 bio101 1
55555 cgdd101 3
55555 swe203 3
55555 eng101 3
11111 bio101 4
11111 cgdd101 4
55555 cs101 1
55555 math101 4
55555 bio101 1
我正在嘗試使用以下pl sql函數計算gpa,但出現以下錯誤。
55555 eng101 3
36 rows selected.
SQL> create or replace function get_count
2 return is
3 declare
4 v_count number;
5 begin
6 select count(*) into v_count from grade;
7 return grade;
8
9 end;
10 /
Warning: Function created with compilation errors.
SQL> show errors
Errors for FUNCTION GET_COUNT:
LINE/COL ERROR
-------- -----------------------------------------------------------------
2/8 PLS-00103: Encountered the symbol "IS" when expecting one of the
following:
<an identifier> <a double-quoted delimited-identifier> self
long double ref char time timestamp interval date binary
national character nchar
您的函數缺少返回數據類型,例如:
create or replace function get_count
return NUMBER is
v_count number;
...
另外,您不需要declare
。
嘗試這個
CREATE OR REPLACE FUNCTION GET_COUNT
RETURN NUMBER
IS
V_COUNT NUMBER;
BEGIN
SELECT COUNT (*)
INTO V_COUNT
FROM GRADE;
RETURN V_COUNT;
END;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.