oraclealterexecute-immediate

Oracle: Invalid ALTER command in execute immediate


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?


Solution

  • 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'.