PL / SQL过程遇到问题

时间:2018-09-26 18:54:51

标签: sql oracle plsql oracle-sqldeveloper

我有一些PL/SQL块用于分配,但是我在遇到一些麻烦时,两者都可以单独运行,但是当我一次运行全部代码时(我需要分配该代码) ),出现错误。以下是我得到的代码和错误,对于我所缺少的任何帮助将不胜感激。谢谢

DECLARE
Salesbyzip NUMBER(10,2):=0;
inputZip NUMBER(5):=00000;

FUNCTION Zip_Code_Sales(zipcode IN NUMBER)

RETURN NUMBER IS
total_Sales NUMBER(10,2):=0;

BEGIN
    SELECT SUM(GROSS_SALE_PRICE)
    INTO total_Sales
    FROM SALES_OVS
    INNER JOIN CUSTOMERS_OVS ON SALES_OVS.CUST_ID = 
CUSTOMERS_OVS.CUSTOMER_ID
    WHERE zipcode = CUSTOMERS_OVS.Address_zip;
    RETURN total_Sales;
END;

BEGIN
    inputZip:=21009;
    Salesbyzip:=Zip_Code_Sales(inputZip);
    dbms_output.put_line('The total sales for zip code ' || inputZip || 
 ' is $'|| Salesbyzip);
END;

/*4.*/

 DECLARE
zipMostSales NUMBER(5):=00000;

FUNCTION Zip_Code_Max_Sales
RETURN NUMBER IS
maxZip NUMBER(5):=00000;

BEGIN
WITH sales_customers AS
(SELECT ADDRESS_ZIP, COUNT(*) AS Salesbyzip
    FROM SALES_OVS
    INNER JOIN CUSTOMERS_OVS ON SALES_OVS.CUST_ID = 
CUSTOMERS_OVS.CUSTOMER_ID
    GROUP BY ADDRESS_ZIP
    ORDER BY Salesbyzip DESC, ADDRESS_ZIP)
SELECT ADDRESS_ZIP
INTO maxZip
FROM sales_customers
WHERE ROWNUM <= 1;
RETURN maxZip;
END;

BEGIN
zipMostSales:=Zip_Code_Max_Sales;
dbms_output.put_line('The Zipcode with the most sales is ' || 
zipMostSales);
END;
  

错误报告-ORA-06550:第27行,第2列:PLS-00103:遇到   符号“ DECLARE” ORA-06550:第35行,第7列:PLS-00103:   预期出现以下情况之一时遇到符号“ SALES_CUSTOMERS”   以下:

     

  06550。00000-“%s行,%s列:\ n%s”   *原因:通常是PL / SQL编译错误。   *动作:

我希望所有的块都能正常运行,并显示所需的信息。

0 个答案:

没有答案