"localhost:/firebird/data/ILICHEVSK2.FDB". Процедуры Previous topic Chapter index Next topic

REBILLUPDATE

 

Входные параметры

Параметр

Тип

Описание

COMMENT

VARCHAR(255)

 

INVOICEID

INTEGER

 

FROMQUALITYID

INTEGER

 

NET

INTEGER

 

AWEIGHT

INTEGER

 

FROMOWNERID

INTEGER

 

FROMCONTRACTID

INTEGER

 

REGDATE

DATE

 

STORAGEID

INTEGER

 

STATE

INTEGER

 

STORINGID

INTEGER

 

PACKID

INTEGER

 

TOQUALITYID

INTEGER

 

TOOWNERID

INTEGER

 

TOCONTRACTID

INTEGER

 

FROMIT

INTEGER

 

TOIT

INTEGER

 

ORDERLOADITEMID

INTEGER

 

FROMPARTYID

INTEGER

 

TOPARTYID

INTEGER

 

 

Выходные параметры

(Нет выходных параметров)

 

Описание

(Нет описания для процедуры REBILLUPDATE)

 

Определение

CREATE PROCEDURE REBILLUPDATE(
    COMMENT VARCHAR(255),
    INVOICEID INTEGER,
    FROMQUALITYID INTEGER,
    NET INTEGER,
    AWEIGHT INTEGER,
    FROMOWNERID INTEGER,
    FROMCONTRACTID INTEGER,
    REGDATE DATE,
    STORAGEID INTEGER,
    STATE INTEGER,
    STORINGID INTEGER,
    PACKID INTEGER,
    TOQUALITYID INTEGER,
    TOOWNERID INTEGER,
    TOCONTRACTID INTEGER,
    FROMIT INTEGER,
    TOIT INTEGER,
    ORDERLOADITEMID INTEGER,
    FROMPARTYID INTEGER,
    TOPARTYID INTEGER)
AS
declare variable FROMCLASSID integer;
declare variable TOCLASSID integer;
declare variable AOPERATIONPARAM integer;
begin

  select first 1 IT.INVENTORYID
    from IT
    where ((IT.INVOICEID = :INVOICEID) and (IT.OPERATIONID = 17))
  order by IT.INVENTORYID
  into :FROMIT;

  select first 1 IT.INVENTORYID
    from IT
    where ((IT.INVOICEID = :INVOICEID) and (IT.OPERATIONID = 17))
  order by IT.INVENTORYID desc
  into :TOIT;

  if (:STATE is null) then
    STATE = 0;

  select FROMQUALITY.CLASSID, TOQUALITY.CLASSID
     from QUALITY FROMQUALITY
       left join QUALITY TOQUALITY on (TOQUALITY.QUALITYID = :TOQUALITYID)
     where (FROMQUALITY.QUALITYID = :FROMQUALITYID)
  into :FROMCLASSID, :TOCLASSID;

  if (:FROMCLASSID <> :TOCLASSID) then
    AOPERATIONPARAM = 1700;
  else AOPERATIONPARAM = null;

  update IT
  set IT.COMMENT = :COMMENT,
      IT.CONTRACTID = :FROMCONTRACTID,
      IT.NET = -:NET,
      IT.WEIGHT = -:AWEIGHT,
      IT.OWNERID = :FROMOWNERID,
      IT.PROVIDERID = :TOOWNERID,
      IT.REGDATE = :REGDATE,
      IT.STATE = :STATE,
      IT.STORAGEID = :STORAGEID,
      IT.STORINGID = :STORINGID,
      IT.PACKID = :PACKID,
      IT.LABQUALITYID = :FROMQUALITYID,
      IT.BUHQUALITYID = :FROMQUALITYID,
      IT.SAMPLERQUALITYID = :FROMQUALITYID,
      IT.OPERATIONPARAM = :AOPERATIONPARAM,
      IT.ORDERLOADITEMID = :ORDERLOADITEMID,
      IT.PARTYID = :FROMPARTYID
  where (IT.INVENTORYID = :FROMIT);

  update IT
  set IT.COMMENT = :COMMENT,
      IT.CONTRACTID = :TOCONTRACTID,
      IT.NET = :NET,
      IT.WEIGHT = :AWEIGHT,
      IT.OWNERID = :TOOWNERID,
      IT.PROVIDERID = :FROMOWNERID,
      IT.REGDATE = :REGDATE,
      IT.STATE = :STATE,
      IT.STORINGID = :STORINGID,
      IT.PACKID = :PACKID,
      IT.STORAGEID = :STORAGEID,
      IT.LABQUALITYID = :TOQUALITYID,
      IT.BUHQUALITYID = :TOQUALITYID,
      IT.SAMPLERQUALITYID = :TOQUALITYID,
      IT.OPERATIONPARAM = :AOPERATIONPARAM,
      IT.ORDERLOADITEMID = :ORDERLOADITEMID,
      IT.PARTYID = :TOPARTYID
  where (IT.INVENTORYID = :TOIT);
  
end

 

     Previous topic Chapter index Next topic