Home > Net >  Oracle: Invalid ALTER command in execute immediate
Oracle: Invalid ALTER command in execute immediate

Time:01-27

In the procedure, in the ALTER command, I need to dynamically substitute the name of the trigger that needs to be activated.

declare 
v_trg_name varchar2(25) := 'article_comment_audit';
begin 
execute immediate 'ALTER TRIGGER' || v_trg_name || 'ENABLE';
end;

I try to run this code, but it returns an error ORA-00940 invalid ALTER command Please tell me what is the problem?

CodePudding user response:

You'll get 'ALTER TRIGGERarticle_comment_auditENABLE'.

Insert Blanks:

'ALTER TRIGGER ' || v_trg_name || ' ENABLE';

in order to get 'ALTER TRIGGER article_comment_audit ENABLE'.

  • Related