PLS-00103:预期出现以下情况之一时遇到符号"END":= 。( % ;符号";"替换为继续"END"



嗨,我刚刚开始学习PLSQL,目前我遇到了这个错误,但我不确定是什么原因导致了这个问题。

对于我的任务,我应该创建一个PLSQL过程,该过程接受用户输入x,以返回国家及其各自地区的列表。

计数(s_NATIONKEY(印度尼西亚中国德国
R_NAME N_NAME
亚洲131
亚洲145
中东 沙特阿拉伯 132
欧洲132

我建议您创建一个存储过程(而不是匿名PL/SQL块(,然后从任何您想要的地方调用该过程。

我删除了不必要的局部变量声明(因为您从未使用过它们(。

SQL> create or replace procedure numberofsupplier(x in number) is
2  begin
3    -- Print header
4    dbms_output.put_line(lpad('R_name',25) || lpad('N_Name',25) || lpad('Count(s_nationkey)',25));
5    dbms_output.put_line('-------------------' || '-------------------' || '-------------------');
6
7    -- Create an implicit cursor to bring in the data
8    for qrow in (
9                 select r_name, n_name, count(s_nationkey) as cnt
10                     from region , nation, supplier
11                     where r_regionkey = n_regionkey
12                     and n_nationkey = s_nationkey
13                     group by r_name, n_name
14                     having count(s_nationkey) > x
15                     order by r_name)
16    -- Loop through query to print to terminal
17    loop
18      dbms_output.put_line(qrow.r_name || qrow.n_name || qrow.cnt);
19    end loop;
20  end;
21  /
Procedure created.

我们称之为

SQL> -- Executes Procedure
SQL> set serveroutput on
SQL> begin
2    numberofsupplier(&userinput);
3  end;
4  /
Enter value for userinput: 1
R_name                   N_Name       Count(s_nationkey)
---------------------------------------------------------
PL/SQL procedure successfully completed.

由于我的桌子是空的,所以没有输出,但是——你可能应该看到一些东西(使用你的桌子(。

相关内容

最新更新