程序有什么问题?
What is wrong in the program?
我已经在包中创建了过程...在 TOAD 中编译时没有错误,但是在提交我的 jsp 页面后它显示
""package body "USERINFO.FORM_PKG" has errors ORA-06508: PL/SQL: could
not find program unit being called: "USERINFO.FORM_PKG"""
CREATE OR REPLACE PACKAGE form_pkg AS -- package body
PROCEDURE Insert_receipts(
p_receipt NUMBER,
p_transaction NUMBER,
p_amount NUMBER);
PROCEDURE Insert_stkqntys(
p_itemid NUMBER,
p_date VARCHAR2,
p_supplier VARCHAR2,
p_type VARCHAR2,
p_transaction NUMBER,
p_quantity NUMBER);
END form_pkg;
/
CREATE OR REPLACE PACKAGE BODY form_pkg AS -- package body
PROCEDURE Insert_receipts (
p_receipt NUMBER(6),
p_transaction NUMBER(5),
p_amount NUMBER(10),
seq_value NUMBER) IS
BEGIN
INSERT INTO receipt
( ID, Receipt_Number,Transaction_ID,Amount)
VALUES (seq.nextval, p_receipt, p_transaction, p_amount);
END Insert_receipts
;
PROCEDURE Insert_stkqntys
(
p_itemid NUMBER(8),
p_date VARCHAR2(50),
p_supplier VARCHAR2(50),
p_type VARCHAR2(50),
p_transaction NUMBER(8),
p_quantity NUMBER,
seq_value NUMBER) IS
BEGIN
INSERT INTO stock_quantity(ID,Item_ID,Date_Received,Supplier_Challan,Transaction_Type,Transaction_ID,Quantity)VALUES (seq.nextval, p_itemid, p_date,p_supplier,p_type,p_transaction,p_quantity);
END Insert_stkqntys;
End form_pkg;
/
过程/函数的声明在 package
及其 body
中必须相等。尽量避免 幻数
like p_amount NUMBER(10)
: 10
是什么意思?但是使用 p_amount receipt.Amount%Type
这很清楚
receipt.Amount
字段的类型。
CREATE OR REPLACE PACKAGE form_pkg AS
-- interface: procedure with 3 arguments
PROCEDURE Insert_receipts(
p_receipt receipt.Receipt_Number%Type,
p_transaction receipt.Transaction_ID%Type,
p_amount receipt.Amount%Type);
...
END form_pkg;
/
CREATE OR REPLACE PACKAGE BODY form_pkg AS -- package body
-- implementation
-- The same three arguments (no seq_value!)
PROCEDURE Insert_receipts (
p_receipt receipt.Receipt_Number%Type,
p_transaction receipt.Transaction_ID%Type,
p_amount receipt.Amount%Type)
IS
BEGIN
INSERT INTO receipt(
ID,
Receipt_Number,
Transaction_ID,
Amount)
VALUES (
seq.NextVal,
p_receipt,
p_transaction,
p_amount);
END Insert_receipts;
...
END form_pkg;
/
执行例程时,您可以在 USER_ERRORS
视图中查看错误的详细信息(名称、行等):
-- all (syntactic) errors in the form_pkg
select *
from USER_ERRORS
where Name = upper('form_pkg')
每个 procedure/function 的包装规格和正文应具有相同的 arguments/data 类型,并且不能包含 size/scale/precision。
此外,使用 [SCHEMA_NAME.]TABLE_NAME.COLUMN_NAME%TYPE
而不是显式声明类型。但是,如果您要使用基础数据类型,则只需删除精度。 IE。 p_receipt NUMBER(6)
应该只是 p_receipt NUMBER
而没有 size/scale/precision.
CREATE OR REPLACE PACKAGE form_pkg AS -- package specification
PROCEDURE Insert_receipts(
p_receipt RECEIPT.RECEIPT_NUMBER%TYPE,
p_transaction RECEIPT.TRANSACTION_ID%TYPE,
p_amount RECEIPT.AMOUNT%TYPE
);
PROCEDURE Insert_stkqntys(
p_itemid STOCK_QUANTITY.ITEM_ID%TYPE,
p_date STOCK_QUANTITY.DATE_RECEIVED%TYPE,
p_supplier STOCK_QUANTITY.SUPPLIER_CHALLAN%TYPE,
p_type STOCK_QUANTITY.TRANSACTION_TYPE%TYPE,
p_transaction STOCK_QUANTITY.TRANSACTION_ID%TYPE,
p_quantity STOCK_QUANTITY.QUANTITY%TYPE
);
END form_pkg;
/
CREATE OR REPLACE PACKAGE BODY form_pkg AS -- package body
PROCEDURE Insert_receipts (
p_receipt RECEIPT.RECEIPT_NUMBER%TYPE,
p_transaction RECEIPT.TRANSACTION_ID%TYPE,
p_amount RECEIPT.AMOUNT%TYPE
)
IS
BEGIN
INSERT INTO receipt (
ID,
Receipt_Number,
Transaction_ID,
Amount
) VALUES (
seq.nextval,
p_receipt,
p_transaction,
p_amount
);
END Insert_receipts;
PROCEDURE Insert_stkqntys
(
p_itemid STOCK_QUANTITY.ITEM_ID%TYPE,
p_date STOCK_QUANTITY.DATE_RECEIVED%TYPE,
p_supplier STOCK_QUANTITY.SUPPLIER_CHALLAN%TYPE,
p_type STOCK_QUANTITY.TRANSACTION_TYPE%TYPE,
p_transaction STOCK_QUANTITY.TRANSACTION_ID%TYPE,
p_quantity STOCK_QUANTITY.QUANTITY%TYPE
)
IS
BEGIN
INSERT INTO stock_quantity(
ID,
Item_ID,
Date_Received,
Supplier_Challan,
Transaction_Type,
Transaction_ID,
Quantity
) VALUES (
seq.nextval,
p_itemid,
p_date,
p_supplier,
p_type,
p_transaction,
p_quantity
);
END Insert_stkqntys;
End form_pkg;
/
我已经在包中创建了过程...在 TOAD 中编译时没有错误,但是在提交我的 jsp 页面后它显示
""package body "USERINFO.FORM_PKG" has errors ORA-06508: PL/SQL: could not find program unit being called: "USERINFO.FORM_PKG"""
CREATE OR REPLACE PACKAGE form_pkg AS -- package body
PROCEDURE Insert_receipts(
p_receipt NUMBER,
p_transaction NUMBER,
p_amount NUMBER);
PROCEDURE Insert_stkqntys(
p_itemid NUMBER,
p_date VARCHAR2,
p_supplier VARCHAR2,
p_type VARCHAR2,
p_transaction NUMBER,
p_quantity NUMBER);
END form_pkg;
/
CREATE OR REPLACE PACKAGE BODY form_pkg AS -- package body
PROCEDURE Insert_receipts (
p_receipt NUMBER(6),
p_transaction NUMBER(5),
p_amount NUMBER(10),
seq_value NUMBER) IS
BEGIN
INSERT INTO receipt
( ID, Receipt_Number,Transaction_ID,Amount)
VALUES (seq.nextval, p_receipt, p_transaction, p_amount);
END Insert_receipts
;
PROCEDURE Insert_stkqntys
(
p_itemid NUMBER(8),
p_date VARCHAR2(50),
p_supplier VARCHAR2(50),
p_type VARCHAR2(50),
p_transaction NUMBER(8),
p_quantity NUMBER,
seq_value NUMBER) IS
BEGIN
INSERT INTO stock_quantity(ID,Item_ID,Date_Received,Supplier_Challan,Transaction_Type,Transaction_ID,Quantity)VALUES (seq.nextval, p_itemid, p_date,p_supplier,p_type,p_transaction,p_quantity);
END Insert_stkqntys;
End form_pkg;
/
过程/函数的声明在 package
及其 body
中必须相等。尽量避免 幻数
like p_amount NUMBER(10)
: 10
是什么意思?但是使用 p_amount receipt.Amount%Type
这很清楚
receipt.Amount
字段的类型。
CREATE OR REPLACE PACKAGE form_pkg AS
-- interface: procedure with 3 arguments
PROCEDURE Insert_receipts(
p_receipt receipt.Receipt_Number%Type,
p_transaction receipt.Transaction_ID%Type,
p_amount receipt.Amount%Type);
...
END form_pkg;
/
CREATE OR REPLACE PACKAGE BODY form_pkg AS -- package body
-- implementation
-- The same three arguments (no seq_value!)
PROCEDURE Insert_receipts (
p_receipt receipt.Receipt_Number%Type,
p_transaction receipt.Transaction_ID%Type,
p_amount receipt.Amount%Type)
IS
BEGIN
INSERT INTO receipt(
ID,
Receipt_Number,
Transaction_ID,
Amount)
VALUES (
seq.NextVal,
p_receipt,
p_transaction,
p_amount);
END Insert_receipts;
...
END form_pkg;
/
执行例程时,您可以在 USER_ERRORS
视图中查看错误的详细信息(名称、行等):
-- all (syntactic) errors in the form_pkg
select *
from USER_ERRORS
where Name = upper('form_pkg')
每个 procedure/function 的包装规格和正文应具有相同的 arguments/data 类型,并且不能包含 size/scale/precision。
此外,使用 [SCHEMA_NAME.]TABLE_NAME.COLUMN_NAME%TYPE
而不是显式声明类型。但是,如果您要使用基础数据类型,则只需删除精度。 IE。 p_receipt NUMBER(6)
应该只是 p_receipt NUMBER
而没有 size/scale/precision.
CREATE OR REPLACE PACKAGE form_pkg AS -- package specification
PROCEDURE Insert_receipts(
p_receipt RECEIPT.RECEIPT_NUMBER%TYPE,
p_transaction RECEIPT.TRANSACTION_ID%TYPE,
p_amount RECEIPT.AMOUNT%TYPE
);
PROCEDURE Insert_stkqntys(
p_itemid STOCK_QUANTITY.ITEM_ID%TYPE,
p_date STOCK_QUANTITY.DATE_RECEIVED%TYPE,
p_supplier STOCK_QUANTITY.SUPPLIER_CHALLAN%TYPE,
p_type STOCK_QUANTITY.TRANSACTION_TYPE%TYPE,
p_transaction STOCK_QUANTITY.TRANSACTION_ID%TYPE,
p_quantity STOCK_QUANTITY.QUANTITY%TYPE
);
END form_pkg;
/
CREATE OR REPLACE PACKAGE BODY form_pkg AS -- package body
PROCEDURE Insert_receipts (
p_receipt RECEIPT.RECEIPT_NUMBER%TYPE,
p_transaction RECEIPT.TRANSACTION_ID%TYPE,
p_amount RECEIPT.AMOUNT%TYPE
)
IS
BEGIN
INSERT INTO receipt (
ID,
Receipt_Number,
Transaction_ID,
Amount
) VALUES (
seq.nextval,
p_receipt,
p_transaction,
p_amount
);
END Insert_receipts;
PROCEDURE Insert_stkqntys
(
p_itemid STOCK_QUANTITY.ITEM_ID%TYPE,
p_date STOCK_QUANTITY.DATE_RECEIVED%TYPE,
p_supplier STOCK_QUANTITY.SUPPLIER_CHALLAN%TYPE,
p_type STOCK_QUANTITY.TRANSACTION_TYPE%TYPE,
p_transaction STOCK_QUANTITY.TRANSACTION_ID%TYPE,
p_quantity STOCK_QUANTITY.QUANTITY%TYPE
)
IS
BEGIN
INSERT INTO stock_quantity(
ID,
Item_ID,
Date_Received,
Supplier_Challan,
Transaction_Type,
Transaction_ID,
Quantity
) VALUES (
seq.nextval,
p_itemid,
p_date,
p_supplier,
p_type,
p_transaction,
p_quantity
);
END Insert_stkqntys;
End form_pkg;
/