我正在为我的作业而努力。当我运行它时,我收到错误:
PACKAGE PKG_Q4 Compiled.
Warning: execution completed with warning
PACKAGE BODY PKG_Q4 Compiled.
50/12 PLS-00330: invalid use of type name or subtype name.
我已经调查了这个,但我似乎无法找到解决方法。它指向这一行:
INTO v_Room_Number, v_Pet_Status, v_Customer_Source_Description, v_Invoice_Total
这是我的代码:
CREATE OR REPLACE PACKAGE BODY PKG_Q4
AS
FUNCTION FN_Q4
(p_First_Name VARCHAR2, p_Last_Name VARCHAR2)
RETURN VARCHAR2
AS
v_Output VARCHAR2(500);
v_Room_Number NUMBER(3,0);
v_Pet_Status CHAR(1);
v_Customer_Source_Description VARCHAR2(30);
v_Invoice_Total NUMBER(7,2);
v_First_Name VARCHAR2(15);
v_Last_Name VARCHAR2(20);
v_Customer_Code CHAR(4);
v_Registration_Status_Code CHAR(1);
BEGIN
SELECT First_Name, Last_Name
INTO v_First_Name, v_Last_Name
FROM Customer
WHERE First_Name = p_First_Name AND
Last_Name = p_Last_Name;
Select Registration_Status_Code
INTO v_Registration_Status_Code
FROM Registration_Status;
IF v_Registration_Status_Code = 'N' THEN
SELECT Room.Room_Number, Room.Pet_Status, Customer_Source.Customer_Source_Description, Invoice.Invoice_Total
INTO v_Room_Number, v_Pet_Status, v_Customer_Source_Description, v_Invoice_Total
FROM Registration , Customer , Customer_Source , Room , Invoice
WHERE Customer.customer_code = Registration.customer_code AND
Customer_Source.customer_source_code = Customer.customer_source_code AND
Room.room_number = Registration.room_number AND
Registration.registration_number = Invoice.registration_number;
v_Output := 'Room Number:' || v_Room_Number ||'Pet Status:' || v_Pet_Status ||
'Customer Source Code:' || v_Customer_Source_Description ||'Total Cost:' || v_Invoice_Total;
END IF;
Return Varchar2;
答案 0 :(得分:4)
我打赌这个问题实际上是这行,在代码摘录的最底部:
Return Varchar2;
“Varchar2”是一种类型,不能将它用作RETURN语句的参数。在函数声明中,RETURN VARCHAR2
是正确的用法,表示函数返回的值的类型。实际的RETURN语句应返回该类型的值,如
RETURN 'This is a string literal';
在你的情况下,我猜你想要:
RETURN v_Output;