I am trying to get data from 4 tables FACTS_CDPM, PRODUCT, CUSTOMER, DATE into CUST_ALLOC table, when I just run the select query, i get the result, but when I put it inside a procedure and do an insert into with the select statement as below, I get an error "Error(11,15): PL/SQL: ORA-04044: procedure, function, package, or type is not allowed here"
Please can somebody help as to why this is happening?
Thank you!
INSERT INTO CUST_ALLOC
(PART_ID,
CUSTOMER,
MONTH,
QTY_ALLOCATED
)
SELECT P.PROD_ID,
C.PURCHASING,
D.MONTH_ID,
SUM(X.QTY)
FROM FACTS_CDPM X INNER JOIN PRODUCT P ON P.PROD_NUM=X.PROD_NUM
INNER JOIN CUSTOMER C ON X.CUST_NUM=C.CUST_NUM
INNER JOIN DATE D ON X.DATE_NUM=D.DATE_NUM
WHERE MEASURE_NUM=18
GROUP BY P.PROD_ID,C.PURCHASING,D.MONTH_ID;
DATE
is a reserved keyword in Oracle. Your procedure shouldn't even compile if it contained the insert statement you posted. If you're going to use DATE for a table name, put it in quotes:
INNER JOIN "DATE" ON X.DATE_NUM="DATE".DATE_NUM
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With