插入日期時,我有以下SQL腳本,以填補使用PL/SQL隨機數據的「佈告」表:「PL/SQL:ORA-00984:列在這裏不允許」錯誤從功能
DECLARE
dgStartDate DATE;
dgEndDate DATE;
dgRandomDate DATE;
FUNCTION getRandomDate(pStartDate IN DATE, pEndDate IN DATE) RETURN DATE
IS
dRandomDate DATE;
piStartNumber PLS_INTEGER;
piEndNumber PLS_INTEGER;
BEGIN
piStartNumber := TO_NUMBER(TO_CHAR(pStartDate, 'J'));
piEndNumber := TO_NUMBER(TO_CHAR(pEndDate, 'J'));
dRandomDate := TO_DATE(TRUNC(DBMS_RANDOM.VALUE(piStartNumber, piEndNumber)), 'J');
RETURN dRandomDate;
END;
BEGIN
dgStartDate := TO_DATE('01/01/2012', 'DD/MM/YYYY');
dgEndDate := TO_DATE('31/12/2015', 'DD/MM/YYYY');
dgRandomDate := getRandomDate(dgStartDate, dgEndDate);
FOR loop_counter IN 1..28 LOOP
INSERT INTO billings(id_billing, id_account, total_billing, due_billing)
VALUES (loop_counter, '123456', round(DBMS_RANDOM.VALUE(0,2000),2), TO_CHAR(dRandomDate, 'DD/MM/YYYY'));
END LOOP;
COMMIT;
END;
我收到以下錯誤:
ORA-06550: line 45, column 76:
PL/SQL: ORA-00984: column not allowed here
ORA-06550: line 44, column 1:
PL/SQL: SQL Statement ignored
的錯誤是在INSERT語句中的日期部分,但日期函數返回正確的值。我不知道如何使它工作。
在此先感謝
看起來我們有不同的行號,哪一行是44? –