在下面的过程中,我想为approval_log_id列插入多个id记录,该列是approval_redirect_log表的外键。
我从另一个表approval_log获取approval_log_id。第一列的select查询返回应与其他数据一起插入的多个id。必须为所有ID重复其他列数据。
我在第一栏的错误是什么?
PROCEDURE REDIRECT_APPROVAL_LOG_INSERT(
vAPPROVAL_LOG_ID approval_redirect_log.approval_log_id%type,
vREDIRECTED_FROM APPROVAL_REDIRECT_LOG.redirected_from%type,
vREDIRECTED_TO APPROVAL_REDIRECT_LOG.redirected_to%type,
vREDIRECTED_BY approval_redirect_log.redirected_by%type) AS
BEGIN
INSERT INTO APPROVAL_REDIRECT_LOG(
APPROVAL_LOG_ID,
REDIRECTED_FROM,
REDIRECTED_TO,
REDIRECTED_BY,
REDIRECTED_ON)
VALUES
(select approval_log_id
from approval_log
where accept_reject is null and approval_recid=vREDIRECTED_FROM
,
vREDIRECTED_FROM,
vREDIRECTED_TO,
vREDIRECTED_BY,
sysdate
);
END REDIRECT_APPROVAL_LOG_INSERT;
答案 0 :(得分:2)
你应该:
INSERT INTO APPROVAL_REDIRECT_LOG(
APPROVAL_LOG_ID,
REDIRECTED_FROM,
REDIRECTED_TO,
REDIRECTED_BY,
REDIRECTED_ON)
select approval_log_id,
vREDIRECTED_FROM,
vREDIRECTED_TO,
vREDIRECTED_BY,
sysdate
from approval_log
where
accept_reject is null
and approval_recid=vREDIRECTED_FROM;