BEGIN;
UPDATE dsm_services SET merged_in = NULL WHERE merged_in = :dsId;
DELETE FROM dsm_apiparams USING dsm_api WHERE api = dsm_api.id AND api.service = :dsId;
DELETE FROM api WHERE service = :dsId;
DELETE FROM dsm_service_organization WHERE service = :dsId;
DELETE FROM dsm_servicepids WHERE service = :dsId;
DELETE FROM dsm_services WHERE id = :dsId;
COMMIT;