数据库记录里有 3条记录记录1  20
记录2  20
记录3  20输入一个数值 得到的效果如下数值 50
记录1  0
记录2  0
记录3  10
给点思路 搞不定了 -.-!!

解决方案 »

  1.   

    意思是把结果减50?那简单啊  得到表的结果集,然后用输入值(x)比较提取出来的值(y),如果(x)大的话,那么y = 0;x -= y;一直到 (x)小于 (y);那么y -= x;结束循环。 
      

  2.   

    这个数值是通过其他数据计算出来的 不用管它现在比如数值结果是 n:=50; 
    *数据库记录
    -------------
    记录1  20 
    记录2  20 
    记录3  20 
    -------------
    那么我开是循环并Edit数据库记录 减去记录的数值 一直减到n为0比如 记录1的数据室20  那么n:=n-20 记录1=0;
    n<>0的话下一条 这个循环不会做了 
      

  3.   

    写得一般般,将就用吧
    /*
    create table t1 (a varchar(10),b int,c int)
    insert into t1 values ('记录1',20,0)
    insert into t1 values ('记录2',20,0)
    insert into t1 values ('记录3',20,0)drop table t1
    *//*
    CREATE FUNCTION fs (@id int) 
    RETURNS int AS 
    BEGIN 
        DECLARE @s int
        select @s= isnull(sum(b),0) from t2 where id < @id
        select @s = @s+ b from t2 where id = @id
        RETURN @s
    END
    *//*CREATE  procedure dbo.updatetable
    @v int
    as
        select IDENTITY(INT,1,1) as id,* into t2 from t1
        update t2 set c = dbo.fs(id)
        update t2 set c =0 where c <= @v
        update t2 set c = c - @v where b = (select min(b) from t2 where b>0)
        update t2 set c =0 where c <= 0
        update t2 set b = c where c <= b
        select * from t2
        drop table t2--drop procedure updatetable
    */exec updatetable 30--result
    1 记录1 0 0
    2 记录2 10 10
    3 记录3 20 30
      

  4.   


    delphi 数据库是 Access
      

  5.   

    delphi 我不懂 没办法了