0
votes

I am trying to run a plsql block that retrieves the customerid, quantity, sale_date, and product.

It gives the following error message

END; Error report - ORA-06550: line 5, column 31: PL/SQL: ORA-00911: invalid character ORA-06550: line 3, column 8: PL/SQL: SQL Statement ignored 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action:

Here is my code all help would be appreciated.

SET SERVEROUTPUT ON
DECLARE
    CURSOR CUR_HISTORY IS 
         SELECT CUST#, SALE_DATE, QTY, DESCRIPTION
         FROM SALES S, PRODUCT P
       WHERE CUST# = &CUST#
       AND S.PRODUCT# = P.PRODUCT#;       

    TYPE TYPE_HISTORY IS RECORD (
       CID      SALES.CUST#%TYPE,
       SDT  SALES.SALE_DATE%TYPE,
       QTY  SALES.QTY%TYPE,
       PNAME    PRODUCT.DESCRIPTION%TYPE);  
    REC_HISTORY     TYPE_HISTORY;

BEGIN
    OPEN CUR_HISTORY;
         LOOP 
         FETCH CUR_HISTORY INTO REC_HISTORY;
         EXIT WHEN CUR_HISTORY%NOTFOUND;
   DBMS_OUTPUT.PUT_LINE('CUSTOMER ID: '   
          ||REC_HISTORY.CID|| ' ORDER DATE: ' || 
          REC_HISTORY.ODT|| '   QTY: ' 
          ||REC_HISTORY.QTY|| 'PRODUCT: ' 
          ||REC_HISTORY.PNAME);   
       END LOOP;
    CLOSE CUR_HISTORY;     
END;
1

1 Answers

0
votes

In your put_line you have

... 
ORDER DATE: ' || REC_HISTORY.ODT  
...

There is no ODT field in your record type TYPE_HISTORY, instead you have SDT. Therefore I believe a typo in your record type declaration.