【发布时间】:2017-02-06 23:14:20
【问题描述】:
我正在编写一个 DML 包,我想在包中创建一个简单的过程来更新 Commission_pct 值。执行包主体时没有收到任何语法错误,但是当我调用该过程时收到意外错误。谢谢。
PROCEDURE update_commission_pct(
p_empid employees.employee_id%TYPE,
p_new_comm employees.commission_pct%TYPE
)
IS
rec_confirm employees%ROWTYPE;
v_valid_empid BOOLEAN;
BEGIN
-- Simple boolean function to check employee existence
v_valid_empid := dml_employees_pkg.check_employee_id(p_empid);
IF
v_valid_empid = TRUE
AND LENGTH(p_new_comm) <=5 THEN
UPDATE employees
SET commission_pct = p_new_comm
WHERE employee_id = p_empid
RETURNING employee_id, commission_pct
INTO rec_confirm.employee_id, rec_confirm.commission_pct;
DBMS_OUTPUT.PUT_LINE('Comission updated successfully.');
DBMS_OUTPUT.PUT_LINE('Employee ID number ' ||
rec_confirm.employee_id || ' new comm is' ||
rec_confirm.commission_pct);
ELSE
RAISE_APPLICATION_ERROR(-20042, 'Employee ID ' ||
p_empid || ' Employee doesn't exist.');
END IF;
END update_commission_pct;
在一个简单的 PL/SQL 块中调用过程:
SET SERVEROUTPUT ON
BEGIN
dml_employees_pkg.update_commission_pct(550, 10);
END;
甲骨文错误:
Informe de error -
ORA-01438: value larger than specified precision allowed for this column
ORA-06512: at "HR.DML_EMPLOYEES_PKG", line 118
ORA-06512: at line 2
01438. 00000 - "value larger than specified precision allowed for this column"
*Cause: When inserting or updating records, a numeric value was entered
that exceeded the precision defined for the column.
*Action: Enter a value that complies with the numeric column's precision,
or use the MODIFY option with the ALTER TABLE command to expand
the precision.
【问题讨论】:
标签: oracle stored-procedures plsql package