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

DESK_JOURNAL_UPDATE

 

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

Параметр

Тип

Описание

INVENTORYID

INTEGER

 

OPERATIONID

INTEGER

 

TRANSPORTTYPEID

INTEGER

 

REGDATE

DATE

 

TRANSPORTNUMBER

VARCHAR(31)

 

INVOICEID

INTEGER

 

INVOICEGROSS

INTEGER

 

INVOICETARE

INTEGER

 

INVOICENET

INTEGER

 

TARE

INTEGER

 

GROSS

INTEGER

 

NET

INTEGER

 

SAMPLERINDATE

DATE

 

ORDERLOADITEMID

INTEGER

 

STORAGEID

INTEGER

 

PROVIDERID

INTEGER

 

OWNERID

INTEGER

 

TARETIME

TIMESTAMP

 

GROSSTIME

TIMESTAMP

 

SILAGEID

INTEGER

 

ROUTEID

INTEGER

 

PLATFORMID

INTEGER

 

WEIGHTNUMBER

INTEGER

 

SAMPLERQUALITYID

INTEGER

 

STATE

INTEGER

 

 

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

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

 

Описание

Обновление для журнала ЖД силосной доски

 

Определение

CREATE PROCEDURE DESK_JOURNAL_UPDATE(
    INVENTORYID INTEGER,
    OPERATIONID INTEGER,
    TRANSPORTTYPEID INTEGER,
    REGDATE DATE,
    TRANSPORTNUMBER VARCHAR(31),
    INVOICEID INTEGER,
    INVOICEGROSS INTEGER,
    INVOICETARE INTEGER,
    INVOICENET INTEGER,
    TARE INTEGER,
    GROSS INTEGER,
    NET INTEGER,
    SAMPLERINDATE DATE,
    ORDERLOADITEMID INTEGER,
    STORAGEID INTEGER,
    PROVIDERID INTEGER,
    OWNERID INTEGER,
    TARETIME TIMESTAMP,
    GROSSTIME TIMESTAMP,
    SILAGEID INTEGER,
    ROUTEID INTEGER,
    PLATFORMID INTEGER,
    WEIGHTNUMBER INTEGER,
    SAMPLERQUALITYID INTEGER,
    STATE INTEGER)
AS
begin
  if (SAMPLERINDATE is null) then
    if (REGDATE is not null) then
      SAMPLERINDATE = REGDATE;
    else SAMPLERINDATE = Current_Date;

  if (not exists (select INVENTORYID from ITTRANSPORT where (INVENTORYID = :INVENTORYID))) then
    insert into ITTRANSPORT (INVENTORYID, TRANSPORTNUMBER, INVOICEGROSS,
                             INVOICETARE, INVOICENET, SAMPLERINDATE, TRANSPORTTYPEID)
      values (:INVENTORYID, :TRANSPORTNUMBER, :INVOICEGROSS,
              :INVOICETARE, :INVOICENET, :SAMPLERINDATE, :TRANSPORTTYPEID);
  else
    update ITTRANSPORT
    set TRANSPORTNUMBER = :TRANSPORTNUMBER,
        INVOICEGROSS = :INVOICEGROSS,
        INVOICETARE = :INVOICETARE,
        INVOICENET = :INVOICENET,
        SAMPLERINDATE = :SAMPLERINDATE,
        TRANSPORTTYPEID = :TRANSPORTTYPEID
    where (INVENTORYID = :INVENTORYID);

  if ((:OPERATIONID = 1) and (not ((:ROUTEID is null) and (:PLATFORMID is null)))) then begin
    if ((not :ROUTEID is null) and (exists (select * from ROUTECHEMA where ROUTECHEMA.ROUTECHEMAID = :ROUTEID))) then
      update ROUTECHEMA
      set PLATFORMID = :PLATFORMID
      where (ROUTECHEMA.ROUTECHEMAID = :ROUTEID);
    else begin
      if (ROUTEID is null) then
        ROUTEID = GEN_ID(ROUTECHEMAIDGEN, 1);
      insert into ROUTECHEMA (ROUTECHEMAID, PLATFORMID)
        values (:ROUTEID, :PLATFORMID);
    end
  end

  if (not exists (select INVENTORYID from IT where INVENTORYID = :INVENTORYID)) then
    insert into IT (INVENTORYID, REGDATE, INVOICEID, ORDERLOADITEMID, STORAGEID,
                    OWNERID, PROVIDERID, TARETIME, GROSSTIME, GROSS, TARE, NET,
                     WEIGHTNUMBER, SAMPLERQUALITYID, OPERATIONID, STATE, ROUTEID)
      values (:INVENTORYID, :REGDATE, :INVOICEID, :ORDERLOADITEMID, :STORAGEID,
              :OWNERID, :PROVIDERID, :TARETIME, :GROSSTIME, :GROSS, :TARE, :NET,
              :WEIGHTNUMBER, :SAMPLERQUALITYID, :OPERATIONID, :STATE, :ROUTEID);  --add last
  else
    update IT
    set REGDATE = :REGDATE,
        INVOICEID = :INVOICEID,
        STORAGEID = :STORAGEID,
        OWNERID = :OWNERID,
        PROVIDERID = :PROVIDERID,
        SILAGEID = :SILAGEID,
        ROUTEID = :ROUTEID,
        ORDERLOADITEMID = :ORDERLOADITEMID,
        TARETIME = :TARETIME,
        GROSSTIME = :GROSSTIME,
        GROSS = :GROSS,
        TARE = :TARE,
        NET = :NET,
        WEIGHTNUMBER = :WEIGHTNUMBER,
        SAMPLERQUALITYID = :SAMPLERQUALITYID,
        OPERATIONID = :OPERATIONID,
        STATE = :STATE
    where (INVENTORYID = :INVENTORYID);

end

 

     Previous topic Chapter index Next topic