我在包体内创建了一个函数,用于计算客户数据库中当前客户的数量,并创建了一个创建客户的函数。但我不确定我需要在包装本身里面放什么。这是包体内的代码。
FUNCTION count_customer
RETURN NUMBER is
total NUMBER;
BEGIN
SELECT COUNT(*) into total FROM customer;
RETURN (total);
END;
FUNCTION CREATE_CUSTOMER(
Country IN VARCHAR2
,First_Name IN VARCHAR2
,Last_Name IN VARCHAR2
,Birth_Date IN VARCHAR2
,Customer_Type IN VARCHAR2
,Address IN VARCHAR2
) return VARCHAR2 IS
new_customer_id VARCHAR2(8);
BEGIN
SELECT custid_seq.NEXTVAL
INTO new_customer_id
FROM DUAL;
INSERT INTO customer (Customer_id, Country, First_Name, Last_name, Birth_date, Customer_Type, Address)
VALUES (new_customer_id, Country, First_Name, Last_name, Birth_date, Customer_Type, Address);
total_customers := total_customers + 1;
RETURN (new_customer_id);
end;
然后稍后在包体中我有这个来计算新的计数。
BEGIN
total_customers := count_customer();
END;
我遇到的问题是在实际包装中放入什么。我已经让创建客户在包内工作,这只是客户数量我遇到问题。
有什么想法吗?