帮助解析分配的组和角色

帮助解析分配的组和角色

本文介绍了帮助解析分配的组和角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的问题


表1是包含以下列的报告列表


报告ID,报告名称,组允许,角色允许

1报告1职员,经理用户,PowerUser


表2是用户列表


UserID,用户名,群组,角色

u1 John Doe文员用户

u2 Jane Doe经理PowerUser


怎么做我循环通过报告表1并在用户表2中选择基于组和角色的报告?


我已经有了解析列的功能

如下


CREATE FUNCTION ParseString2Table



@SourceString varchar(100)




退回@retTable TABLE



TextValue varchar(10)




AS


BEGIN

de clare @string varchar(500)

set @string = @SourceString

声明@pos int

声明@piece varchar(10)


/ * - 需要在输入字符串末尾添加分隔符(如果不存在)* /

如果正确(rtrim(@string) ),1)<> '',''

设置@string = @string +'',''


set @pos = patindex(''%,%''' ,@ string)

而@pos<> 0

开始

设置@piece = left(@string,@ post - 1)


/ * - 你有一段数据,所以插入,打印,随心所欲。* /

INSERT INTO @retTable VALUES(cast(@piece as varchar(10)))


设置@string = stuff(@string,1,@ post,'''')

set @pos = patindex(''%,%'', @string)

结束


返回


结束


我需要一些循环通过报告表而不使用游标的方式和

检查用户权限


请帮助...

This is my problem

Table 1 is a list of reports that have the following columns

Report ID, Report Name, Groups Allowed, Roles Allowed
1 Report 1 Clerk, Mgr User, PowerUser

Table 2 is a list of users

UserID, User Name, Group, Role
u1 John Doe Clerk User
u2 Jane Doe Mgr PowerUser

How do i loop thru the reports table 1 and select the reports based on Group and Role in the user table 2?

I have already got a function to parse the columns
as follows


CREATE FUNCTION ParseString2Table
(
@SourceString varchar(100)
)

RETURNS @retTable TABLE
(
TextValue varchar(10)
)

AS

BEGIN
declare @string varchar(500)
set @string = @SourceString
declare @pos int
declare @piece varchar(10)

/*-- Need to tack a delimiter onto the end of the input string if one doesn''t exist*/
if right(rtrim(@string),1) <> '',''
set @string = @string + '',''

set @pos = patindex(''%,%'' , @string)
while @pos <> 0
begin
set @piece = left(@string, @pos - 1)

/*-- You have a piece of data, so insert it, print it, do whatever you want to with it.*/
INSERT INTO @retTable VALUES( cast(@piece as varchar(10)))

set @string = stuff(@string, 1, @pos, '''')
set @pos = patindex(''%,%'' , @string)
end

RETURN

END

I need some way of looping thru the reports table without using a cursor and
checking the user permissions

Help Please...

推荐答案




我想我不应该使用User&经理作为例子。

让我们说两个不同的部门 - 制造与发展完成


所以Groups Allowed列是varchar(1000)并且将是

" MAN,FIN,DELIVERY"

和允许的角色columnd也是varchar(1000),类似于

" User,PowerUser"


Well I guess I should not have used User & Mgr as examples.
Let''s say 2 different departments - Manufacturing & Finishing

so the Groups Allowed column is varchar (1000) and would be
"MAN, FIN, DELIVERY"
and the Roles Allowed columnd is also varchar(1000) and would be something like
"User, PowerUser"



这篇关于帮助解析分配的组和角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 11:43