0
我在這裏試圖做的不是反覆運行插入代碼,這就是我決定創建一個存儲過程的原因。下面是存儲過程的腳本,它已成功創建,但是當我執行存儲過程「BEGIN SP_INSERT_PMC_UPDATE_DP; END;」時我收到錯誤信息「*在調用的參數錯誤的數量或類型來SP_INSERT_PMC_UPDATE_DP *」Oracle 11g代碼上的PL/SQL是執行存儲過程的時候
我的想法和SP代碼對這個框架是:
1 - 我檢查,看看是否有記錄的PMC_UPDATE_DP並將該值放入RECORD_COUNT。
2-現在,如果RECORD_COUNT大於零,我想清除PMC_UPDATE_DP表中的所有記錄。
3-如果RECORD_COUNT等於零,那麼我想從EXTERNAL_PMC_UPDATE_FD表中插入數據到PMC_UPDATE_DP。
CREATE OR REPLACE PROCEDURE PMC.SP_INSERT_PMC_UPDATE_DP
(RECORD_COUNT OUT NUMBER) --Is my issue here???
IS
BEGIN
--Returns the total records and adds the value to RECORD_COUNT variable.
SELECT COUNT(*)
INTO RECORD_COUNT
FROM PMC.PMC_UPDATE_DP;
--Condition to see if RECORD_COUNT is greater than zero and dumps data to clear out PMC.PMC_UPDATE_DP table.
IF RECORD_COUNT > 0 THEN
EXECUTE IMMEDIATE 'TRUNCATE TABLE PMC.PMC_UPDATE_DP';
END IF;
--Condition to see if RECORD_COUNT equals zero. If true insert data into PMC_UPDATE_DP table from the PMC.EXTERNAL_PMC_UPDATE_FD table.
IF RECORD_COUNT = 0 THEN
INSERT INTO PMC.PMC_UPDATE_DP
( JOB_ID,
CONTROL_ID,
ACCT_NO,
CALC_DIVIDEND,
CERT_NEW_SHARES,
CALC_CASH_DISBURSMENT,
DECEASED,
STATUS,
ALPHA_SP1,
ALPHA_SP2,
ALPHA_SP3,
ALPHA_SP4,
NUM_SP1,
NUM_SP2,
NUM_SP3,
NUM_SP4,
DONT_CALL,
DONT_MAIL
)
SELECT JOB_ID,
CONTROL_ID,
ACCT_NO,
CALC_DIVIDEND,
CERT_NEW_SHARES,
CALC_CASH_DISBURSMENT,
DECEASED,
STATUS,
ALPHA_SP1,
ALPHA_SP2,
ALPHA_SP3,
ALPHA_SP4,
NUM_SP1,
NUM_SP2,
NUM_SP3,
NUM_SP4,
DONT_CALL,
DONT_MAIL
FROM PMC.EXTERNAL_PMC_UPDATE_FD
COMMIT;
END IF;
END;