BEGIN DECLARE sqlStmt VARCHAR2(512); curUser VARCHAR2(100); BEGIN select SYS_CONTEXT('USERENV','CURRENT_USER') into curUser from dual; sqlStmt := 'BEGIN ' || 'OPTIMIZERSTATISTICS.FORCEMCMSTATISTICS(''' || curUser || '''); ' || 'OPTIMIZERSTATISTICS.GATHERSCHEMASTATISTICS(''' || curUser || '''); ' || 'END;'; execute immediate sqlStmt; execute immediate 'update cmpinstallation_v set statsgatheredon = sysdate '; execute immediate 'commit '; END; END;