首页 > 解决方案 > 警告:在 plsql 中创建的包体存在编译错误...

问题描述

错误:

警告:包体创建时出现编译错误。BEGIN * ERROR at line 1: ORA-04063: package body "P12284.EMP_DESIGNATION" has errors ORA-06508: PL/SQL: could not find program unit being called: "P12284.EMP_DESIGNATION" ORA-06512: at line 2

如何解决这个?请帮助我,我是 PL/SQL 新手

`

set serveroutput on;
    CREATE OR REPLACE PACKAGE EMP_DESIGNATION 
    AS
    PROCEDURE EMP_DETAILS(PS_design employee.designation%TYPE, PS_incentive number);
    END EMP_DESIGNATION;
    /
    CREATE OR REPLACE PACKAGE BODY EMP_DESIGNATION
    AS
    PROCEDURE EMP_DETAILS(design employee.designation%TYPE, incentive number)
    IS
    BEGIN
        update employee set employee.salary = employee.salary + incentive where designation = design ;
        DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT || ' employee(s) are updated');
         
    END;
    /
    `

标签: sqloracleplsqlplsql-package

解决方案


你有两个问题,

  1. 的签名emp_details应该在规范和正文中匹配

  2. 您忘记了end包正文中的程序。

    CREATE OR REPLACE PACKAGE emp_designation AS
    PROCEDURE emp_details
      (
        ps_design    employee.designation%TYPE
      , ps_incentive NUMBER
      );
    END emp_designation;
    /
    
    CREATE OR REPLACE PACKAGE BODY emp_designation AS
      PROCEDURE emp_details
        ( 
          ps_design employee.designation%TYPE
        , ps_incentive NUMBER
        ) 
      IS
      BEGIN
        UPDATE employee SET employee.salary = employee.salary + ps_incentive 
          WHERE designation = ps_design; 
        dbms_output.put_line(SQL%ROWCOUNT || ' employee(s) are updated');
      END emp_details;
    END;
    /
    

推荐阅读