错误:PL / SQL:ORA-00904 ::无效的标识符

时间:2014-06-23 09:23:48

标签: oracle stored-procedures plsql ora-00904

CREATE OR REPLACE PACKAGE pls_check2 AS
  PROCEDURE check_proc(p_item_cat       NUMBER,
                       p_sub_cat        NUMBER,
                       p_pack_is        NUMBER,
                       p_pack_name      NUMBER,
                       v1           OUT NUMBER,
                       v2           OUT NUMBER,
                       v3           OUT NUMBER,
                       v4           OUT NUMBER);

  PROCEDURE package_info1(param1 NUMBER, param2 NUMBER, param3 NUMBER);
END pls_check2;


CREATE OR REPLACE PACKAGE BODY pls_check2 AS
  v1  NUMBER;
  v2  NUMBER;
  v3  NUMBER;
  v4  NUMBER;

  PROCEDURE check_proc(p_item_cat       NUMBER,
                       p_sub_cat        NUMBER,
                       p_pack_is        NUMBER,
                       p_pack_name      NUMBER,
                       v1           OUT NUMBER,
                       v2           OUT NUMBER,
                       v3           OUT NUMBER,
                       v4           OUT NUMBER) IS
    CURSOR c1 IS
      SELECT ic.id
        FROM itemcategory ic
       WHERE ic.id = p_item_cat;
  BEGIN
    v1 := p_item_cat;
    v2 := p_sub_cat;
    v3 := p_pack_is;
    v4 := p_pack_name;

    FOR c_p IN c1 LOOP
      INSERT INTO master_product_table
        (SELECT NULL,
                NULL,
                package_info1(c_p.id, v2, v3)
           FROM package);
    END LOOP;

    DBMS_OUTPUT.put_line('hello');
  END;

  PROCEDURE package_info1(param1 NUMBER, param2 NUMBER, param3 NUMBER) IS
    v_is_incentivized  VARCHAR2(20);
  BEGIN
    SELECT is_incentivized
      INTO v_is_incentivized
      FROM package pk
     WHERE pk.id = 1;

    DBMS_OUTPUT.put_line('hi');
  END;
END pls_check2;

编译后出现错误:

Error(18,1): PL/SQL: SQL Statement ignored
Error(33,7): PL/SQL: ORA-00904: : invalid identifier   

1 个答案:

答案 0 :(得分:0)

您尝试从SQL调用PROCEDURE。这是不允许的(因为它没有意义)。将package_info1更改为

function package_info1(param1 NUMBER, param2 NUMBER, param3 NUMBER)
    return number;
包标题中的

function package_info1(param1 NUMBER, param2 NUMBER, param3 NUMBER)
    return number IS
  v_is_incentivized  VARCHAR2(20);
  BEGIN
    SELECT is_incentivized
      INTO v_is_incentivized
      FROM package pk
     WHERE pk.id = 1;

    DBMS_OUTPUT.put_line('hi');
    RETURN 1;
  END;

在包体中,它将编译。不过,我真的建议你重命名你的PACKAGE表 - 这个名字会让你痛苦不已。