0
我正在嘗試使用類型和costperlb引用郵件類型表來計算傳遞成本來創建一個存儲過程來填充郵件表。插入需要引用另一個表的字段的存儲過程
我不斷得到的是:24/1 PL/SQL:忽略SQL語句 25/50 PL/SQL:ORA-00984:列不允許在這裏。 我一直在嘗試解決這個問題一段時間;我只剩下幾個小時了。任何幫助,將不勝感激。
CREATE TABLE MAILTYPE(
TYPEID NUMBER PRIMARY KEY,
NAME VARCHAR2(30) NOT NULL,
COSTPERLB DECIMAL NOT NULL
);
CREATE TABLE MAIL (
ID NUMBER PRIMARY KEY,
STATUS VARCHAR2(30) NOT NULL,
DATE_RECEIVED DATE NOT NULL,
DATE_DELIEVED DATE NOT NULL,
CUSTID NUMBER,
TYPEID NUMBER,
RECIPIENTID NUMBER,
WEIGHT DECIMAL,
COST DECIMAL
CONTRAINT...
);
CREATE OR REPLACE PROCEDURE INSERT_MAIL
(
ID NUMBER,
STATUS VARCHAR2,
DATE_RECEIVED DATE,
DATE_DELIEVED DATE,
CUSTID NUMBER,
TYPEID NUMBER,
RECIPIENTID NUMBER,
WEIGHT DECIMAL,
COST DECIMAL
)
AS
M_TOTAL DECIMAL;
COST_PER DECIMAL;
BEGIN
IF (to_char(SYSDATE,'DY') IN ('MON', 'TUE', 'WED', 'THU', 'FRI')) AND (TO_CHAR(SYSDATE,'HH24') IN ('9','10','11','12','13','14','15','16','17'))
THEN
INSERT INTO MAIL (ID,STATUS,DATE_RECEIVED,DATE_DELIVERED,CUSTID,TYPEID,RECIPIENTID,WEIGHT, cost)
VALUES(CUSTOMER_SEQ.nextval,STATUS,DATE_RECEIVED,DATE_DELIVERED,CUSTID,TYPEID,RECIPIENTID,WEIGHT,cost);
IF (TYPEID = 1) THEN
SELECT COSTPERLB INTO COST_PER FROM SEANTEE_DA.MAILTYPE
WHERE SEANTEE_DA.MAILTYPE.TYPEID = 1;
M_TOTAL := COST_PER * WEIGHT;
UPDATE MAIL SET COST = M_TOTAL
WHERE TYPEID = 1;
end if;
IF (TYPEID = 2) THEN
SELECT COSTPERLB INTO COST_PER FROM SEANTEE_DA.MAILTYPE
WHERE MAILTYPE.TYPEID = 2;
M_TOTAL := COST_PER * WEIGHT;
UPDATE MAIL SET COST = M_TOTAL
WHERE TYPEID = 2;
END IF;
IF (TYPEID = 3) THEN
SELECT COSTPERLB INTO COST_PER FROM SEANTEE_DA.MAILTYPE
WHERE SEANTEE_DA.MAILTYPE.TYPEID = 3 ;
M_TOTAL := COST_PER * WEIGHT;
UPDATE MAIL SET COST = M_TOTAL
WHERE TYPEID = 3;
END IF;
END IF;
COMMIT;
END;
/