Sounds like you have a delete that is not completed yet. You can fix this 2 ways:
1. Download EMDIAG repvfy and run repvfy verify targets -fix
2. Go to Setup -> Manage Cloud Control -. Health Overview, look for a link in the top quarter section that says pending deletes or something like that, click the # beside it, and select the target and there should be a "force delete" button.
Once that's done, if you want to delete host and agent and all monitored targets in one shot, the best option is to use emcli delete_target verb:
emcli delete_target -name="test.example.com:1836" -type="oracle_emd" -delete_monitored_targets -async
The error "Unknown error. java.sql.SQLException: ORA-20242:" points to all targets monitored by the Agent are not removed including the host target
Ensure to stop the agent before running the emcli delele target command i.e
+Run the following command to stop the Management Agent:
$<AGENT_INSTANCE_HOME>/bin/emctl stop agent
+Run the following EMCLI command to delete the Management Agent target on the old OMS:
$<OMS_HOME>/bin/emcli delete_target -delete_monitored_targets -name=<name_of_agent_target> -type="oracle_emd"
+For more information about the delete_target EMCLI command, refer Oracle Enterprise Manager Command Line Interface Guide.
I had the same error with an Agent and was unable to remove the AGENT!
The way I was able to force the removal was to navigate to the associated HOST and select Target Setup > Remove Target. This removes the host. You should then be able to remove the agent. This will leave residual files for cleanup on the host machine. Follow local agent uninstall instructions in the user guide, on windows this includes running the setup.exe in burried in the agent_inst that will remove files and services for a clean host, so that you can redoploy the agent if needed.
Have a great day!