I think you're using the Test window. This can only execute a single statement. The SQL Window and the Command Window are able to run multiple statements.
If you need to run this in a Test window, you can embed it in a
begin..end block to make it a PL/SQL statement block.