"localhost:/firebird/data/ILICHEVSK2.FDB". ��������� Previous topic Chapter index Next topic

FORWARDER_AVTOQUALITY

 

������� ���������

��������

���

��������

EXPORTACTITEMID

INTEGER

 

 

�������� ���������

��������

���

��������

HUMIDITY

NUMERIC(9,2)

 

DIRT

NUMERIC(9,2)

 

SCREENING

NUMERIC(9,2)

 

 

��������

(��� �������� ��� ��������� FORWARDER_AVTOQUALITY)

 

�����������

CREATE PROCEDURE FORWARDER_AVTOQUALITY(
    EXPORTACTITEMID INTEGER)
RETURNS (
    HUMIDITY NUMERIC(9,2),
    DIRT NUMERIC(9,2),
    SCREENING NUMERIC(9,2))
AS
BEGIN
  FOR
    select
    cast(Sum(quality_select.humidity * exportactitems.weight)  /
    Sum(nullif(exportactitems.weight, 0) + quality_select.humidity - quality_select.humidity) as numeric(9,2)) humidity,
    cast(Sum(quality_select.dirt * exportactitems.weight)  /
         Sum(nullif(exportactitems.weight, 0) + quality_select.dirt - quality_select.dirt) as numeric(9,2)) dirt,
    cast(Sum(quality_select.screening * exportactitems.weight) /
         Sum(nullif(exportactitems.weight, 0) + quality_select.screening - quality_select.screening) as numeric(9,2)) screening
    from exportactitems
     left join it on (exportactitems.inventoryid = it.inventoryid)
     left join exportacts on (exportactitems.exportactid = exportacts.exportactid)
     left join quality_select(case when  exportacts.operationid = 17 then exportacts.qualityid
                                else it.labqualityid end) on (0=0)
    where
      exportactitems.exportactitemid = :exportactitemid
    INTO :humidity,
         :dirt,
         :screening
  DO
  BEGIN
    SUSPEND;
  END
END

 

     Previous topic Chapter index Next topic