本方法适用于商贸版,专业版!旗舰版
问题:用户查询表时,查询不到或者是查询后看不到结果!
原因:用户配置表,用户过滤方案表,用户打印设置表出现了错乱。
一,先清除用户配置表,如果清除以后还有问题,请继续清除下面的表数据。
--根据用户名清除用户配置表
delete t_userprofile where fuserid =(select fuserid from t_user where fname='manager');
二,清除方案表:
--根据用户名清除打印设置方案
delete t_LedgerPageSetup where fuserid =(select fuserid from t_user where fname='manager');
--根据用户名清除用户报表方案表
delete icreportprofile where fuserid =(select fuserid from t_user where fname='manager');
----终极解决方案:触发器解决。(慎用!!会导致用户不能保存查询方案或打印方案)。将以下触发器创建到数据库中去就好了。
--当icreportprofile被插入记录时,触发以下代码
CREATE TRIGGER tri_icreportprofile_Insert
ON icreportprofile
after INSERT
AS
DECLARE
@fuserid INTEGER;
BEGIN
-- 取得插入的 @fuserid
SELECT @fuserid = fuserid FROM INSERTED;
IF EXISTS ( SELECT * FROM icreportprofile WHERE fuserid = @fuserid )
BEGIN
-- 不允许记录被插入,删除记录
DELETE FROM icreportprofile WHERE fuserid = (SELECT fuserid FROM INSERTED);
delete from t_userprofile where fuserid =(SELECT fuserid FROM INSERTED);
delete from t_LedgerPageSetup where fuserid =(SELECT fuserid FROM INSERTED);
END
END
--当t_LedgerPageSetup被插入记录时,触发以下代码
CREATE TRIGGER tri_LedgerPageSetup_Insert
ON t_LedgerPageSetup
after INSERT
AS
DECLARE
@fuserid INTEGER;
BEGIN
-- 取得插入的 @fuserid
SELECT @fuserid = fuserid FROM INSERTED;
IF EXISTS ( SELECT * FROM t_LedgerPageSetup WHERE fuserid = @fuserid )
BEGIN
-- 不允许记录被插入,删除记录
DELETE FROM icreportprofile WHERE fuserid = (SELECT fuserid FROM INSERTED);
delete from t_userprofile where fuserid =(SELECT fuserid FROM INSERTED);
delete from t_LedgerPageSetup where fuserid =(SELECT fuserid FROM INSERTED);
END
END
在执行语句之前,请先备份好数据!!
因本语句造成的一切后果由操作人员承担。