Oracle dynamic SQL considerations ORA-00911: invalid characters

Source: Internet
Author: User
Tags sql using

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: s '')
And inserttime <to_date (: 2, ''yyyy-mm-dd hh24: mi: s '')
Group by trunc (INSERTTIME), TO_CHAR (INSERTTIME, ''hh24''), serviceid, mouduleid, portalid, actionid
)';
Execute immediate lv_ SQL USING p_sdate, p_edate;

-- A semicolon is not required in detailed dynamic statements.

-- The details (''hh24'') must be written in double quotes in a dynamic statement.

-- Details from '| lv_table_name |' pay attention to space characters between statements

-- Detailed usage parameters: 1 USING p_sdate, p_edate;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.