-- -- workflow__delete_role/2 -- create or replace function workflow__delete_role( character varying, character varying ) returns int4 as $$ declare delete_role__workflow_key alias for $1; delete_role__role_key alias for $2; begin /* First, remove all references to this role from transitions */ update wf_transitions set role_key = null where workflow_key = delete_role__workflow_key and role_key = delete_role__role_key; delete from wf_roles where workflow_key = delete_role__workflow_key and role_key = delete_role__role_key; return 0; end;$$ language plpgsql;