Can anyone help me with this error? I wanted to Execute Immediate a Create Table statement that concatenates a table name that will change everyday/month.
This is my code...
DECLARE
v_table_name VARCHAR2(100);
v_get_fromdate VARCHAR2(200);
BEGIN
v_table_name := 'mpiat_after_bs_' || SUBSTR(TO_CHAR(SYSDATE, 'ddmonyy'), 3, 5) || '_t';
v_get_fromdate := 'select GET_FROMDATE(to_date(''01/'|| SUBSTR(TO_CHAR(SYSDATE, 'mmddyy'), 1, 2
) ||'/2017 00:00:00'',''dd/mm/yyyy hh24:mi:ss''),''R'') from dual;';
EXECUTE IMMEDIATE ''
CREATE TABLE ' || v_table_name || ' AS
SELECT column1 ,
column2 ,
column3 ,
column4 ,
column5
FROM table_name
WHERE column1 >=' || v_get_fromdate ||'
AND column3 LIKE ''tbl_%''';
END;
this is the error the I am getting...
Error report -
ORA-00936: missing expression
ORA-06512: at line 7
00936. 00000 - "missing expression"
*Cause:
*Action:
Line 7 is EXECUTE IMMEDIATE 'CREATE TABLE ' || v_table_name || ' AS SELECT column1
I've searched a lot of code regarding this... but I haven't seen anyone concatenates table name as a variable while creating table.
I just wanna know if this is possible. And i am open for any suggestion for this to work. Thank You!