Код: Выделить всё
CREATE TABLE R$OSTATOK (
USERID INTEGER NOT NULL,
GUID INTEGER NOT NULL,
PLACEINDEX INTEGER NOT NULL,
QUANTITY DOUBLE PRECISION DEFAULT 0,
QUANTITYALL DOUBLE PRECISION DEFAULT 0,
MODEDATE DATE DEFAULT current_date
);
Код: Выделить всё
CREATE PROCEDURE CALC_ONE_OSTATOK_DATA (
..........
RETURNS (
PLACEINDEX VARCHAR(80),
QUANTITY DOUBLE PRECISION,
QUANTITYALL DOUBLE PRECISION)
.......
Код: Выделить всё
/* приход и произведенная продукция*/
for
select ns.guid,nh.client2index,sum(ns.quantity) as quantity,sum(ns.quantityall) as quantityall from naclhead nh
left join naclspec ns on nh.id=ns.id and nh.inout=ns.inout
where nh.inout in (0,5,4) and nh.docdate<=:pdate and nh.used='T' and ns.guid=:PGUID
group by ns.guid,nh.client2index
into :LGUID,:placeindex,:LQUANTITY,:LQUANTITYALL
do begin
insert into r$ostatok (userid,guid,placeindex,quantity,quantityall)
values (:puserid,:lguid,:placeindex,:lquantity,:lquantityall);
end