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

CHECKPOINT_UPDATE

 

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

Параметр

Тип

Описание

INVENTORYID

INTEGER

 

PARTYID

INTEGER

 

REGDATE

DATE

 

OPERATIONID

INTEGER

 

INVOICEID

INTEGER

 

ORDERLOADITEMID

INTEGER

 

OWNERID

INTEGER

 

PROVIDERID

INTEGER

 

SAMPLERQUALITYID

INTEGER

 

STORAGEID

INTEGER

 

CONTRACTID

INTEGER

 

STATE

INTEGER

 

BARCODE

VARCHAR(31)

 

TRANSPORTTYPEID

INTEGER

 

TRANSPORTNUMBER

VARCHAR(31)

 

CHECKPOINTINTIME

TIMESTAMP

 

CHECKPOINTOUTTIME

TIMESTAMP

 

INVOICEGROSS

INTEGER

 

INVOICETARE

INTEGER

 

INVOICENET

INTEGER

 

CHECKPOINTSESSION

INTEGER

 

 

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

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

 

Описание

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

 

Определение

CREATE PROCEDURE CHECKPOINT_UPDATE(
    INVENTORYID INTEGER,
    PARTYID INTEGER,
    REGDATE DATE,
    OPERATIONID INTEGER,
    INVOICEID INTEGER,
    ORDERLOADITEMID INTEGER,
    OWNERID INTEGER,
    PROVIDERID INTEGER,
    SAMPLERQUALITYID INTEGER,
    STORAGEID INTEGER,
    CONTRACTID INTEGER,
    STATE INTEGER,
    BARCODE VARCHAR(31),
    TRANSPORTTYPEID INTEGER,
    TRANSPORTNUMBER VARCHAR(31),
    CHECKPOINTINTIME TIMESTAMP,
    CHECKPOINTOUTTIME TIMESTAMP,
    INVOICEGROSS INTEGER,
    INVOICETARE INTEGER,
    INVOICENET INTEGER,
    CHECKPOINTSESSION INTEGER)
AS
declare variable ABARCODE varchar(31);
begin

  if (not exists (select INVENTORYID from ITTRANSPORT where INVENTORYID = :INVENTORYID)) then begin
/*
    if ((select bin_and(coalesce(ENVIRONMENTOPTIONS.BARCODE,0),32) from ENVIRONMENTOPTIONS) = 0) then begin
      BARCODE = '';
      BARCODE = cast(INVENTORYID as varchar(31));

      while (char_length(:BARCODE) < 8) do
        BARCODE = '0' || BARCODE;

      select cast(cast(trunc(rand() * 9999) as integer) as varchar(31))
        from rdb$database
      into :ABARCODE;

      BARCODE = ABARCODE || BARCODE;

      while (char_length(:BARCODE) < 12) do
        BARCODE = '0' || BARCODE;
    end
*/

    insert into ITTRANSPORT (INVENTORYID, BARCODE, TRANSPORTTYPEID, TRANSPORTNUMBER,
      CHECKPOINTINTIME, CHECKPOINTOUTTIME, INVOICEGROSS, INVOICETARE, INVOICENET, CHECKPOINTSESSION)
    values (:INVENTORYID, :BARCODE, :TRANSPORTTYPEID, :TRANSPORTNUMBER, :CHECKPOINTINTIME,
      :CHECKPOINTOUTTIME, :INVOICEGROSS, :INVOICETARE, :INVOICENET, :CHECKPOINTSESSION);
/*
    update ITTRANSPORT
    set BARCODE = :BARCODE
    where (INVENTORYID = :INVENTORYID);
*/
  end
  else begin
    update ITTRANSPORT
    set BARCODE = :BARCODE,
        TRANSPORTTYPEID = :TRANSPORTTYPEID,
        TRANSPORTNUMBER = :TRANSPORTNUMBER,
        CHECKPOINTINTIME = :CHECKPOINTINTIME,
        CHECKPOINTOUTTIME = :CHECKPOINTOUTTIME,
        INVOICEGROSS = :INVOICEGROSS,
        INVOICETARE = :INVOICETARE,
        INVOICENET = :INVOICENET,
        CHECKPOINTSESSION = :CHECKPOINTSESSION
    where (INVENTORYID = :INVENTORYID);
  end

  if (not exists (select INVENTORYID from IT where INVENTORYID = :INVENTORYID)) then
    insert into IT (INVENTORYID, PARTYID, REGDATE, OPERATIONID, INVOICEID, ORDERLOADITEMID,
      OWNERID, PROVIDERID, SAMPLERQUALITYID, STORAGEID, CONTRACTID, STATE)
    values (:INVENTORYID, :PARTYID, :REGDATE, :OPERATIONID, :INVOICEID, :ORDERLOADITEMID,
      :OWNERID, :PROVIDERID, :SAMPLERQUALITYID, :STORAGEID, :CONTRACTID, :STATE);
  else
    update IT
    set PARTYID = :PARTYID,
        REGDATE = :REGDATE,
        OPERATIONID = :OPERATIONID,
        INVOICEID = :INVOICEID,
        ORDERLOADITEMID = :ORDERLOADITEMID,
        OWNERID = :OWNERID,
        PROVIDERID = :PROVIDERID,
        SAMPLERQUALITYID = :SAMPLERQUALITYID,
        STORAGEID = :STORAGEID,
        CONTRACTID = :CONTRACTID,
        STATE = :STATE
    where (INVENTORYID = :INVENTORYID);
end

 

     Previous topic Chapter index Next topic