-1

在下面的过程中,我想为approval_log_id 列插入多个id 记录,该列是approval_redirect_log 表的外键。

我从另一个表approval_log 中获取approval_log_id。第一列的选择查询返回多个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;
4

1 回答 1

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;
于 2013-01-15T12:49:18.927 回答