oracle-databaseplsqloracle11gpls-00103

PLS-00103 error when using COMMENT statement in BEGIN ... END block in PL/SQL


Out of curiosity I'm attempting to use the COMMENT statement in a PL/SQL block. I'm using Oracle APEX 18.2 on an Oracle 11g database and in SQL Workshop I am able to execute the command by itself, but if I wrap it in a BEGIN ... END block then I get an error message like:

ORA-06550: line 4, column 18: PLS-00103: Encountered the symbol "ON" when expecting one of the following: : = . ( @ % ;

Example of command that works:

COMMENT ON COLUMN employees.job_id IS 'comment';

Example of command that results in the error message:

BEGIN  
    COMMENT ON COLUMN employees.job_id IS 'comment';  
END;

I assume that COMMENT isn't a permitted statement in a stored procedure but I haven't been able to find evidence to back this up. Am I correct and if so is this documented anywhere?

Thanks to @GMB for an answer with written example.


Solution

  • Consider:

    create table employees(job_id int);
    
    begin  
        comment on column employees.job_id is 'comment'
    end;
    /
    
    ora-06550: line 2, column 13:
    pls-00103: encountered the symbol "on" when expecting one of the following:
    
       := . ( @ % ;
    
    begin  
        execute immediate 'comment on column employees.job_id is ''comment''' ;
    end;
    /
    
    1 rows affected
    

    db<>fiddle here