如果我运行下面的查询,我会得到ORA-00922和ORA-06512作为错误消息。质疑应该是对的,我做错了什么?
DECLARE query clob; BEGIN query := 'create table cs_trassen_hists_' || to_char(current_date) || ' as select * from cs_trassen_hist'; EXECUTE IMMEDIATE query; END;
字符串
nqwrtyyt1#
您应该指定格式,正如@Mat评论的那样(似乎您没有得到重点)。
SQL> DECLARE 2 query CLOB; 3 BEGIN 4 query := 5 'create table cs_trassen_hists_' 6 || TO_CHAR (CURRENT_DATE, 'yyyymmdd') --> this 7 || ' as select * from dept'; 8 9 EXECUTE IMMEDIATE query; 10 END; 11 / PL/SQL procedure successfully completed. SQL> select * from cs_trassen_hists_20230713; DEPTNO DNAME LOC ---------- -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON SQL>
1条答案
按热度按时间nqwrtyyt1#
您应该指定格式,正如@Mat评论的那样(似乎您没有得到重点)。
字符串