从 CTE 插入
P粉573809727
P粉573809727 2023-08-24 10:57:10
0
2
542
<p><pre class="brush:php;toolbar:false;">使用 DTL AS (选择 CMPI_代码, CMN_CDTY_MTRL, CMI_WT_FACTOR, CMI_CNTRCT_RATE, 'PL', 目前_价格, TRM_代码, ROUND(((NVL(PRESENT_PRICE,1)*CMI_WT_FACTOR) / CMI_CNTRCT_RATE),2) AS PL_FACTOR 来自 VW_CMD_MATERIAL,其中 TRM_CODE = 41) INSERT iNTO IPA_PRCADJ_HDR(TRM_CODE,IPAPH_ADJ_FACTOR,IPAPH_AMT_CUR,IPAPH_REMARKS) 选择 TRM_CODE,SUM(PL_FACTOR) AS PL_FACTOR,((SUM(PL_FACTOR)*10)) AS AMT_CUR,'asdf' FROM DTL GROUP BY (TRM_CODE);; <p>显示错误 ORA-00928: 缺少 SELECT 关键字</p>
P粉573809727
P粉573809727

全部回复(2)
P粉450744515

似乎 Insert 不能用作公用表表达式之后的第一个语句。试试这个,

INSERT iNTO IPA_PRCADJ_HDR(TRM_CODE,IPAPH_ADJ_FACTOR,IPAPH_AMT_CUR,IPAPH_REMARKS)
    SELECT * FROM 
    (

      WITH DTL AS
      (SELECT CMPI_CODE,
             CMN_CDTY_MTRL,
             CMI_WT_FACTOR,
             CMI_CNTRCT_RATE,
             'PL',
             PRESENT_PRICE,
             TRM_CODE,
             ROUND(((NVL(PRESENT_PRICE,1)*CMI_WT_FACTOR) / CMI_CNTRCT_RATE),2) AS PL_FACTOR
      FROM VW_CMD_MATERIAL WHERE TRM_CODE = 41
      )
      SELECT TRM_CODE,SUM(PL_FACTOR) AS PL_FACTOR,((SUM(PL_FACTOR)*10)) AS AMT_CUR,'asdf' 
      FROM DTL GROUP BY (TRM_CODE)
    );
P粉738248522

这是从 CTE 插入表的语法:

-- CREATE TABLE tmp ( tmp_id NUMBER(10) );

INSERT INTO tmp( tmp_id )
  WITH cte AS (
    SELECT 1 AS tmp_id FROM dual
  )
  SELECT tmp_id
  FROM cte;
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!