用友ERP-NC精华实用SQL脚本之:快速复制操作员的权限
来源:互联网 发布:视频下载器for mac 编辑:程序博客网 时间:2024/06/05 09:37
本文作者:草上飞
网址:http://www.newbooks.com.cn
在用友ERP-NC系统的维护过程中,由于员工的流动,我们会经常需要将一个员工的权限复制给另外一个员工。遇到公司比较多的情况时,这个操作可以说是非常麻烦的。在此,我写了一个批处理的脚本,用于方便的复制操作员的权限。本脚本在NC3.0、sql server2000的环境上通过。现我们假设需要将员工A在广东、海南公司的所有权限复制给员工B,则我们可以用以下脚本:
declare @sourceuserid char(20)
declare @touserid char(20)
declare @nowtime char(10)
declare @left4 char(4)
set @left4='AAAA' --注意:每次运行的时候,最好修改这个代码
set @nowtime='2008-01-23 11:00:00' --TS时间,可以任意修改,原则上请改为当前时间
create table #temp(pk_corp char(4))
insert into #temp values('1001') --广东 VALUE为公司的PK值
insert into #temp values('0001') --集团
insert into #temp values('1002') --海南
--如果要复制所有公司的,可以将以上代码三行代码去掉,改为:insert into @temp select pk_corp from bd_corp
select cuserid from sm_user where user_name='员工A' --得到员工A的PK值 假设为0001AA1000000001MVXN
select cuserid from sm_user where user_name='员工B' --得到员工B的PK值 假设为0001AA1000000000445U
--分以下三个操作步骤
set @sourceuserid='0001AA1000000001MVXN' --员工A
set @touserid='0001AA1000000000445U' --员工B
--1.复制来源人关联的公司。
insert into sm_userandcorp
select 0,pk_corp,@left4+right(pk_userandcorp,16),@nowtime,@touserid from sm_userandcorp where userid=@sourceuserid
and pk_corp not in (
select pk_corp from sm_userandcorp where userid=@touserid
) and pk_corp in (select pk_corp from #temp)
--2.复制关联角色
insert into sm_user_rela
select @left4+right(crelaid,16),0,groupid,pk_corp,@nowtime,@touserid from sm_user_rela
where
groupid not in(select groupid from sm_user_rela where userid=@touserid)
and
userid=@sourceuserid and pk_corp in (select pk_corp from #temp)
--3.复制用户的权限。
insert into sm_appuserpower
select @left4+right(cpowerid,16),0,funid,pk_corp,@nowtime,@touserid from sm_appuserpower where userid=@sourceuserid
and funid+pk_corp not in(
select funid+pk_corp from sm_appuserpower where userid=@touserid
) and pk_corp in (select pk_corp from #temp)
drop table #temp
declare @touserid char(20)
declare @nowtime char(10)
declare @left4 char(4)
set @left4='AAAA' --注意:每次运行的时候,最好修改这个代码
set @nowtime='2008-01-23 11:00:00' --TS时间,可以任意修改,原则上请改为当前时间
create table #temp(pk_corp char(4))
insert into #temp values('1001') --广东 VALUE为公司的PK值
insert into #temp values('0001') --集团
insert into #temp values('1002') --海南
--如果要复制所有公司的,可以将以上代码三行代码去掉,改为:insert into @temp select pk_corp from bd_corp
select cuserid from sm_user where user_name='员工A' --得到员工A的PK值 假设为0001AA1000000001MVXN
select cuserid from sm_user where user_name='员工B' --得到员工B的PK值 假设为0001AA1000000000445U
--分以下三个操作步骤
set @sourceuserid='0001AA1000000001MVXN' --员工A
set @touserid='0001AA1000000000445U' --员工B
--1.复制来源人关联的公司。
insert into sm_userandcorp
select 0,pk_corp,@left4+right(pk_userandcorp,16),@nowtime,@touserid from sm_userandcorp where userid=@sourceuserid
and pk_corp not in (
select pk_corp from sm_userandcorp where userid=@touserid
) and pk_corp in (select pk_corp from #temp)
--2.复制关联角色
insert into sm_user_rela
select @left4+right(crelaid,16),0,groupid,pk_corp,@nowtime,@touserid from sm_user_rela
where
groupid not in(select groupid from sm_user_rela where userid=@touserid)
and
userid=@sourceuserid and pk_corp in (select pk_corp from #temp)
--3.复制用户的权限。
insert into sm_appuserpower
select @left4+right(cpowerid,16),0,funid,pk_corp,@nowtime,@touserid from sm_appuserpower where userid=@sourceuserid
and funid+pk_corp not in(
select funid+pk_corp from sm_appuserpower where userid=@touserid
) and pk_corp in (select pk_corp from #temp)
drop table #temp
- 用友ERP-NC精华实用SQL脚本之:快速复制操作员的权限
- 用友ERP-NC精华实用SQL脚本之:快速复制公司的权限
- 用友ERP-NC精华实用SQL脚本之:快速复制公司的部门
- erp 数据权限定义(用友NC)
- 用友ERP/NC--张丹(转自用友网站)
- 用友nc
- SQL 实用精华
- 我下载用友的ERP
- 用友U8与NC的区别?
- 用友ERP U9枚举SQL查询
- PowerBuilder设置操作员对菜单项的操作权限
- 承接用友NC ERP与外系统接口以及二次开发外包
- 用友NC平台之基本概念解析(一)
- 用友NC环境搭建
- 用友NC学习笔记
- 用友NC简介
- 用友、金蝶、神州数码ERP的优势、劣势?
- 用友NC二次开发一些经验以及处理的问题
- QuickTest底层VB脚本驱动
- Gold Coins
- CString ,BSTR ,LPCTSTR之间关系和区别
- 企业网络管理员三大系统命令
- 真正高效的SQLServer中数据分页的通用存储过程
- 用友ERP-NC精华实用SQL脚本之:快速复制操作员的权限
- 老师的苦恼
- struts2学习笔记(2)
- CString 操作指南
- DIV+CSS+javascript实现DIV对象显示在页面任何位置,并随滚动条移动
- 初八,年就这样结束
- Linux 网络子系统底层机制分析(1)
- 葡萄干土豆泥(适全7个月以上婴儿)
- 数学家获得格莱美奖 源自算法成功处理伟大歌手音乐