How to prompt sql if there is no exception
Using 

EXCEPTION
when value_invalid then
null;


is definitively a bad idea, you should not silently suppress the error message.

Try this:

DECLARE
BEGIN
EXECUTE IMMEDIATE 'ALTER SYSTEM SET sga_max_size=12g';
END;
/


Note, inside a PL/SQL Block you have only direct privileges. Privileges granted by role (e.g. DBA role) do not apply inside the block.