【发布时间】:2021-12-20 13:18:49
【问题描述】:
您好,我刚开始学习 PLSQL,目前遇到此错误,但我不确定是什么原因造成的。
对于我的任务,我应该创建一个 PLSQL 过程,该过程接受用户输入 x 以返回国家及其各自地区的列表。
| R_NAME | N_NAME | COUNT(S_NATIONKEY) |
|---|---|---|
| ASIA | INDONESIA | 131 |
| ASIA | CHINA | 145 |
| MIDDLE EAST | SAUDI ARABIA | 132 |
| EUROPE | GERMANY | 132 |
SQL> DECLARE
2 userInput number;
3
4 PROCEDURE numberOfSupplier(x IN number) IS
5 -- Declaring variables to be used
6 r_name region.r_name%type;
7 n_name nation.n_name%type;
8
9
10 BEGIN
11 -- Print header
12 dbms_output.put_line(lpad('R_name',25) || lpad('N_Name',25) || lpad('Count(s_nationkey)',25));
13 dbms_output.put_line('-------------------' || '-------------------' || '-------------------');
14
15 -- Create an implicit cursor to bring in the data
16
17 for Qrow in (
18 select r_name, n_name, count(s_nationkey) AS cnt
19 from region , nation, supplier
20 where r_regionkey = n_regionkey
21 and n_nationkey = s_nationkey
22 group by r_name, n_name
23 having count(s_nationkey) > x
24 order by r_name)
25
26 -- Loop through query to print to terminal
27
28 loop
29 dbms_output.put_line(Qrow.r_name || Qrow.n_name || Qrow.cnt);
30 end loop;
31
32
33 END;
34
35 -- Executes Procedure
36
37 BEGIN
38 userInput := (&MinNumberofsupplier);
39 numberOfSupplier(userInput);
40 END;
41
42 /
这是终端中的错误信息
SQL> show errors;
Errors for PROCEDURE NUMBEROFSUPPLIER:
LINE/COL ERROR
-------- -----------------------------------------------------------------
31/2 PLS-00103: Encountered the symbol "END" when expecting one of the
following:
:= . ( % ;
The symbol ";" was substituted for "END" to continue.
【问题讨论】: