程序错误 - PLS-00103 遇到符号“>”

克里斯蒂娜

我正在尝试学习 PLSQL,但在创建过程时遇到了问题。

我正在解决的任务是:创建一个程序来检查佣金。高于 0.35 的佣金只能输入具有 15 年以上经验的员工。如果佣金较高或实践较低,则会打印错误。利用异常(Exception 和 Raise)来定义错误消息。

我写了这个,但有一个错误:

PLS-00103 在期待以下 ::= 之一时遇到符号“>”。(@%;

create or replace PROCEDURE PROVIZIA(num in number) IS
employee_id number;
com_pct employees.commission_pct%type;
begin
select commission_pct into com_pct from employees where employee_id = num;
if PRAX(employee_id) > 15 then
com_pct > 0.35;
else PRAX(employee_id) < 15 then
com_pct < 0.35;
end if;
exception when com_pct > 0.35 and PRAX(employee_id) < 15 then
dbms_output.put_line('error');
raise;
end PROVIZIA;

你能告诉我我哪里出错了吗?

谢谢。

小脚怪

假设这是一个测试用例(prax返回一些数字的表和函数;我不知道是哪个以及为什么,所以我做了它以便它为员工返回一个“无效”值1):

SQL> create table employees as
  2  select 1 employee_id, 0.5 commission_pct from dual union all
  3  select 2, 0.2 from dual;

Table created.

SQL> create or replace function prax(par_empid in number) return number is
  2  begin
  3    return case when par_empid = 1 then 10
  4                else 50
  5           end;
  6  end prax;
  7  /

Function created.

SQL> select employee_id, commission_pct, prax(employee_id) prax_result
  2  from employees;

EMPLOYEE_ID COMMISSION_PCT PRAX_RESULT
----------- -------------- -----------
          1             ,5          10     --> this combination is invalid
          2             ,2          50     --> this is OK

SQL>

如果值“错误”则引发错误的过程;不做任何其他事情(因为你没有说在这种情况下该怎么做):

SQL> create or replace procedure provizia(num in number) is
  2    com_pct      employees.commission_pct%type;
  3    l_err        exception;
  4  begin
  5    select commission_pct
  6      into com_pct
  7      from employees
  8      where employee_id = num;
  9
 10    if com_pct > 0.35 and prax(num) < 15 then
 11       raise l_err;
 12    end if;
 13
 14  exception
 15    when l_err then
 16      raise_application_error(-20000, 'Error');
 17  end provizia;
 18  /

Procedure created.

SQL>

让我们测试一下:

SQL> exec provizia(num => 1);
BEGIN provizia(num => 1); END;

*
ERROR at line 1:
ORA-20000: Error
ORA-06512: at "SYS.PROVIZIA", line 16
ORA-06512: at line 1


SQL> exec provizia(num => 2);

PL/SQL procedure successfully completed.

SQL>

现在您有了一个工作示例,请随时对其进行改进。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

奇怪的PL / SQL错误-PLS-00103

SQL错误创建过程:PLS-00103:遇到符号“ AS”

函数-oracle(PLS-00103:遇到符号“”)

错误-PLS-00103:遇到符号“ SELECT”

错误:PLS-00103:遇到符号“;” 当期望以下之一时:*&=-+ </> at in是mod余数,不是rem然后

PLS-00103:预期以下情况之一时遇到符号“ ON”

PLS-00103:遇到符号“ SELECT” pl / sql错误

PLS-00103:预期以下情况之一时遇到符号:

PLS-00103在案例中遇到符号“”错误

错误(7,1):PLS-00103:遇到符号“ BEGIN”

Oracle PL / SQL错误PLS-00103

错误(26,14):PLS-00103:预期以下其中一项时遇到符号<cursor>::=。(@%;

PLS-00103:在oracle函数中期望以下其中之一时遇到符号“ IF”

PLS-00103:遇到符号“文件结尾”

PLS-00103:预期以下情况之一时遇到符号“文件结尾”

PLS00103:遇到符号“END”

PLS-00103:在 FlyWay 中遇到符号“文件结束”

PLS-00103:pl/sql 错误

PLS-00103:遇到符号“;” 当期待以下之一时:<an identifier> <ad

PLS-00103:在预期以下错误之一时遇到符号“~”

编译错误,PLS-00103,遇到符号“(”,当预期出现以下情况时:;

Oracle 包错误。PLS-00103:遇到符号“CREATE”

在我的代码中出现错误,例如 PLS-00103:遇到符号“NUM_LARGE”

遇到错误 PLS-00103 符号 - 在输出字符串字段

PLS-00103:在预期以下情况之一时遇到符号“FOR”:

试图编译包体,我得到错误(37,6):PLS-00103:遇到符号“;” 当期待以下之一时:如果

PLS-00103:遇到符號“接受”:

执行 sql 块时出现 PLS-00103 错误(遇到符号“SELECT”...)

PLS-00103:在期待其中一个时遇到符号“CREATE”