Insert into … values ( SELECT … FROM … )

前端 未结 26 2488
我在风中等你
我在风中等你 2020-11-21 05:40

I am trying to INSERT INTO a table using the input from another table. Although this is entirely feasible for many database engines, I always seem to struggle t

26条回答
  •  别跟我提以往
    2020-11-21 06:07

    Here is another example where source is taken using more than one table:

    INSERT INTO cesc_pf_stmt_ext_wrk( 
      PF_EMP_CODE    ,
      PF_DEPT_CODE   ,
      PF_SEC_CODE    ,
      PF_PROL_NO     ,
      PF_FM_SEQ      ,
      PF_SEQ_NO      ,
      PF_SEP_TAG     ,
      PF_SOURCE) 
    SELECT
      PFl_EMP_CODE    ,
      PFl_DEPT_CODE   ,
      PFl_SEC         ,
      PFl_PROL_NO     ,
      PF_FM_SEQ       ,
      PF_SEQ_NO       ,
      PFl_SEP_TAG     ,
      PF_SOURCE
     FROM cesc_pf_stmt_ext,
          cesc_pfl_emp_master
     WHERE pfl_sep_tag LIKE '0'
       AND pfl_emp_code=pf_emp_code(+);
    
    COMMIT;
    

提交回复
热议问题