"localhost:/firebird/data/ILICHEVSK2.FDB". ��������� Previous topic Chapter index Next topic

WEIGHTWRITE

 

������� ���������

��������

���

��������

DETERIORATION

NUMERIC(9,2)

 

INVENTORYID

INTEGER

 

TOTALWEIGHT

INTEGER

 

TOTALNET

INTEGER

 

PLUGUNDERWORK

INTEGER

 

ISLAST

INTEGER

 

SUMBEFORE

INTEGER

 

 

�������� ���������

��������

���

��������

RESULT

INTEGER

 

 

��������

������ � ������ ��������� ���� � �������� (����� 3)

 

�����������

CREATE PROCEDURE WEIGHTWRITE(
    DETERIORATION NUMERIC(9,2),
    INVENTORYID INTEGER,
    TOTALWEIGHT INTEGER,
    TOTALNET INTEGER,
    PLUGUNDERWORK INTEGER,
    ISLAST INTEGER,
    SUMBEFORE INTEGER)
RETURNS (
    RESULT INTEGER)
AS
DECLARE VARIABLE WEIGHT INTEGER;
DECLARE VARIABLE NET INTEGER;
DECLARE VARIABLE K NUMERIC(9,6);
begin
  select it.net from it where it.inventoryid = :inventoryid
  into :NET;
 --   PERCENT = ((cast(:net as numeric(9,2))/:totalnet)*100);
 --   WEIGHT =  :PERCENT * :totalweight/100;
 --   WEIGHT = :net - (:net * ((cast(:deterioration as numeric(9,4))/100)));
 --   WEIGHT =  :net * cast((100- (cast(:deterioration as numeric(9,4))))/100 as numeric(9,2));
    if (:plugunderwork = 1) then
    begin
 --     detDw = ((:detD * (:NET))/100);
--      dethw = (((:deth/100) * ((:net) - :detDw)));
--      totalweight = totalweight
--        Suma = :SUMA + :WEIGHT;
        K = 100 - :deterioration;
--        ((cast(:totalweight as numeric(9,2)) * 100/ :totalnet));
        if (:islast = 1) then
          weight = (:totalweight - :sumbefore);
        else
        begin
          weight = (cast(:NET as double precision) * :K) / 100;
        end
    end
    else
      WEIGHT =  :net * (100- (cast(:deterioration as numeric(9,2))))/100;

  result = :WEIGHT;

  update it set it.weight = :WEIGHT where it.inventoryid = :inventoryid;

  suspend;
end

 

     Previous topic Chapter index Next topic