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

UPDATESILAGEQUALITY

 

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

Параметр

Тип

Описание

SILAGEPACKID

INTEGER

 

 

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

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

 

Описание

Проверка наличия SilageQuality & QualityID
И его установка

 

Определение

CREATE PROCEDURE UPDATESILAGEQUALITY(
    SILAGEPACKID INTEGER)
AS
declare variable SQID integer;
declare variable QID integer;
declare variable QUPDATE integer;
declare variable WEIGHT integer;
begin
  select SILAGEPACKS.SILAGEQUALITYID, SILAGEPACKS.QUALITYID, SILAGEPACKS.WEIGHT
    from SILAGEPACKS
    where (SILAGEPACKS.SILAGEPACKID = :SILAGEPACKID)
  into :SQID, :QID, :WEIGHT;

  if ((SQID is null) or (QID is null)) then
    QUPDATE = 1;
  else QUPDATE = 0;

  if (QID is null) then begin
    QID = gen_id(QUALITYIDGEN, 1);
    insert into QUALITY (QUALITYID)
    values (:QID);
  end

  if (SQID is null) then begin
    SQID = gen_id(SILAGEQUALITYIDGEN, 1);
    insert into silagequality (SILAGEQUALITYID, QUALITYID, WEIGHT)
    values (:SQID, :QID, :WEIGHT);
  end

  if (QUPDATE = 1) then begin
    update SILAGEPACKS
    set QUALITYID = :QID,
        SILAGEQUALITYID = :SQID
    where (SILAGEPACKID = :SILAGEPACKID);
  end

  suspend;
END

 

     Previous topic Chapter index Next topic