oracle 動態SQL 注意細節 ORA-00911: 無效字元

來源:互聯網
上載者:User

  lv_sql:='
  insert into ETL_SUCESS_AMOUNT
  select SEQ_OS_ETL_AMOUNTID.NEXTVAL AS AMOUNTID,1,AMOUNT_DATA,AMOUNT_HOUR,
  serviceid,portalid,mouduleid,actionid,RESERVE1_ID,RESERVE2_ID,RESERVE3_ID,
  RESERVE4_ID,AMOUNT,AMOUNT_TIME
  from
  (
    select
    trunc(INSERTTIME) AS AMOUNT_DATA,
    TO_CHAR(INSERTTIME,''HH24'') AS AMOUNT_HOUR,
    serviceid,portalid,mouduleid,actionid,
    NULL AS RESERVE1_ID,
    NULL AS RESERVE2_ID,
    NULL AS RESERVE3_ID,
    NULL AS RESERVE4_ID,
    count(*) AS AMOUNT,
    SYSDATE AS AMOUNT_TIME
    from '||lv_table_name||'
    where inserttime > to_date(:1,''yyyy-mm-dd hh24:mi:ss'')
    and  inserttime < to_date(:2,''yyyy-mm-dd hh24:mi:ss'')
    group by trunc(INSERTTIME),TO_CHAR(INSERTTIME,''HH24''),serviceid,mouduleid,portalid,actionid
  )';
  execute immediate lv_sql USING p_sdate,p_edate;

-- 細節動態語句裡面不需要分號

--細節(''HH24'') 動態語句裡面單引號要雙寫

--細節 from '||lv_table_name||'  語句之間注意空格符號

--細節使用參數:1   USING p_sdate,p_edate;

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.