oracle 在存储过程中创建表

y0u0uwnf  于 2022-11-22  发布在  Oracle
关注(0)|答案(1)|浏览(188)

我已经在oracle中创建了一个存储过程,用于为现有表创建备份表。在执行SP时,我遇到错误。

create or replace PROCEDURE proc_clear_table_for_automation_temp
IS
   sql_stmt    VARCHAR2(200);
begin
    sql_stmt := 'create table transaction_method_' || SYSDATE || ' as (select * from transaction_method)';  
    execute immediate sql_stmt;  
END;
i have created above procedure but while executing it using
exec proc_clear_table_for_automation_temp;

i am getting following error

Error starting at line : 11 in command -
BEGIN proc_clear_table_for_automation_temp; END;
Error report -
ORA-00922: missing or invalid option
ORA-06512: at "REL55.PROC_CLEAR_TABLE_FOR_AUTOMATION_TEMP", line 7
ORA-06512: at line 1
00922. 00000 -  "missing or invalid option"
*Cause:    
*Action:

Can someone help on this
syqv5f0l

syqv5f0l1#

使用SYSDATE到字符串的显式转换
例如:

'create table transaction_method_' || to_char(SYSDATE,'yyyymmdd')

可以避免表名中可能存在的无效空格。

相关问题