openspecimen
Database
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
assign_to_role
Parameters
Name
Type
Mode
role_name
text
IN
resource_name
text
IN
operations
text
IN
Definition
begin select identifier into @role_id from rbac_roles where name = role_name; select identifier into @resource_id from rbac_resources where name = resource_name; insert into rbac_role_access_list (role_id, resource_id) values (@role_id, @resource_id); select last_insert_id() into @acl_id; set @operations = operations; set @occurrences = length(@operations) - length(replace(@operations, ',', '')); oploop: while (@occurrences >= 0) do set @opName = substring_index(@operations, ',', 1); if (@opName != '') THEN select identifier into @op_id from rbac_operations where name = @opName; insert into rbac_role_access_list_ops (operation_id, acl_id) values (@op_id, @acl_id); else leave oploop; end if; set @occurrences = length(@operations) - length(replace(@operations, ',', '')); if (@occurrences = 0) then leave oploop; end if; set @operations = substring(@operations,length(substring_index(@operations, ',', 1)) + 2); end while; end