一个简单的方法:
1、加字段,比如为A char null,这里放审核者登录号或者审核者电脑名等可以唯一标志审核者的信息。
2、添加记录的时候A 为 null
3、提取的时候,先提取A=自己标志的记录,解决因为死机问题遗留的记录
4、没有A=自己标志的记录,就提取A is null的记录
应该不难吧

解决方案 »

  1.   

    这样好了,在用户在客户端取这条数据的时候就在数据库端更新这条数据的时间,然后再根据用户后来提交的所修改的内容将这条数据的其他字段update掉
      

  2.   

    想到一个办法:在表中加个时间字段,表示记录被提取的时间取记录的时候,从时间字段为NULL值,以及与当前时间比较,超过某个时间的记录.
    然后更新被取记录的时间为当前时间.规定记录被审核的时间必须在一个时间段内,超过这个时间段的被自动释放
      

  3.   

    还是 CSDNM 的方法简单.至少自己是肯定知道自己那些是该取的.我的方法可以做为备用方案,在取完所有自己的之后再使用
    得到工作站标识可以用:host_id()
    得到工作站名称可以用:host_name()
    得到登陆的用户名可以用:suser_sname()
      

  4.   

    create proc 提取记录
    @A char(20)              ---审核者
    asdeclare @id int
    BEGIN TRANSACTION
    select top 1 @id=id from tablename with (ROWLOCK) 
    where 某字段=2
    and a=@a
    order by time 
    if @@rowcount=0
    begin
     select top 1 @id=id from tablename with (UPDLOCK) 
     where 某字段=2
     and a is null
     order by time 
     if @@rowcount=0
     begin
       Commit TRANSACTION    --无记录退出
       return 
     end
    end
    update tablename set a=@a
    where id=@id
    Commit TRANSACTION 
    select * from tablename where id=@id
    go
      

  5.   

    更正:create proc 提取记录
    @A char(20)              ---审核者
    asdeclare @id int
    BEGIN TRANSACTION
    select top 1 @id=id from tablename with (UPDLOCK) 
    where 某字段=2
    and a=@a
    order by time 
    if @@rowcount=0
    begin
     select top 1 @id=id from tablename with (UPDLOCK) 
     where 某字段=2
     and a is null
     order by time 
     if @@rowcount=0
     begin
       Commit TRANSACTION    --无记录退出
       return 
     end
    end
    update tablename set a=@a
    where id=@id
    Commit TRANSACTION 
    select * from tablename where id=@id
    go
      

  6.   

    --在表中增加几个字段: 
    read_time --读取记录的时间
    host_name --读取记录的电脑名称
    read_user --读取记录的操作员--在 CSDNM 的基础上修改(结合两种方法)create proc 提取记录
    @read_user char(20)  ---审核者
    as
    declare @id intBEGIN TRANSACTION
    --从本机,本人读取的记录中取
    select top 1 @id=id from tablename with (UPDLOCK) 
    where 某字段=2
    and [host_name]=host_name()
    and read_user=@read_user
    order by time  if @@rowcount=0 --如果没有,从没有被读取的记录中读取
    begin
     select top 1 @id=id from tablename with (UPDLOCK) 
     where 某字段=2
    and(host_name is null
    or read_user is null)
     order by time   if @@rowcount=0 --如果没有,从超时的记录中读取
     begin
     select top 1 @id=id from tablename with (UPDLOCK) 
     where 某字段=2
    and read_time<datediff(hout,-1,getdate())  --假设超时时间为1小时
     order by time  if @@rowcount=0 --无记录退出
    begin
       commit tran
       return 
    end
    end
    end update tablename set 
    read_user=@read_user,
    [host_name]=host_name(),
    read_time=@read_time
    where id=@id
    commit transaction 
    select * from tablename where id=@id
    go
      

  7.   

    谢谢!! 刚我自己用方法测试成功!
    但是还是有个问题
    就是我定义了个变量比如
     @declare @tmp varchar(100)
    select @tmp = '##good'
    create table @tmp (nouse int)最后一行报错误, 我希望能够用变量做创建表的名字,怎么搞?
      

  8.   

    --因为你是全局的临时表,所以可以这样定义:exec('create table '+@tmp+' (nouse int)')
      

  9.   

    --用全局临时表,用户环境下,控制得不好会引起冲突--建议用下面的方法生成临时表名@declare @tmp sysname
    set @tmp = '[##good'+cast(newid() as varchar(36))+']'
    exec('create table '+@tmp+'(nouse int)')
      

  10.   

    不好意思,我不是故意发这么多帖的, 也浪费我这么多分:)
       原因是我的adsl modem 最近老遭受攻击,即打开网页时候老返回ttl=1路由不可到达错误。 但其他的提交什么却可以! 每次都要重新启动modem(配置好了nat),我发这个帖子的时候就碰到了这个问题!! 我没看到结果,就按了f5,还没看到, 又按了f5,等我反应过来的时候就这样了
    其实我只开了2个帖子,在vb, sqlserver个开了一个, 实在是不好意思!!
      

  11.   

    to zjcxc: 
    用你的方法已经搞定了, 下面是我的操作BEGIN TRANSACTION
    declare @id bigint
    select top 1 @id=id from tv where status=2 and object_id('tempdb..##' +cast(id as varchar(100))) is null order by id asc
    exec('create table ##'+@id+'(nouse int)')
    select * from tv where id = @id
    commit transaction 等待审核,到vb用变量记录下那个id来BEGIN TRANSACTION
    update tv set status = 4  where id = vb记录的id变量
    drop table ## + vb记录的id变量
    commit transaction等下给分!