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

IT_ORDERLOADIDBYINVOICEID

 

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

Параметр

Тип

Описание

INVOICEID

INTEGER

 

 

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

Параметр

Тип

Описание

ORDERLOADID

INTEGER

 

 

Описание

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

 

Определение

CREATE PROCEDURE IT_ORDERLOADIDBYINVOICEID(
    INVOICEID INTEGER)
RETURNS (
    ORDERLOADID INTEGER)
AS
declare variable COUNTID integer;
begin
  select count(distinct coalesce(ORDERLOADITEMS.ORDERLOADID, 0))
    from IT
      left join ORDERLOADITEMS on (ORDERLOADITEMS.ORDERLOADITEMID = IT.ORDERLOADITEMID)
    where (IT.INVOICEID = :INVOICEID) and (IT.STATE >= 0)
      and ((IT.ORDERLOADITEMID > 0) and (IT.ORDERLOADITEMID is not null))
 into :COUNTID;

  if (:COUNTID > 1) then
    exception EDOUBLEORDERLOADITEMS;

  select distinct ORDERLOADITEMS.ORDERLOADID
    from IT
      left join ORDERLOADITEMS on (ORDERLOADITEMS.ORDERLOADITEMID = IT.ORDERLOADITEMID)
    where (IT.INVOICEID = :INVOICEID) and (IT.STATE >= 0)
      and ((IT.ORDERLOADITEMID > 0) and (IT.ORDERLOADITEMID is not null))
  into :ORDERLOADID;

  suspend;

end

 

     Previous topic Chapter index Next topic