This commit is contained in:
parent
a995d80b46
commit
d0f1362f85
|
@ -16,16 +16,16 @@ BEGIN
|
||||||
DECLARE cTickets CURSOR FOR
|
DECLARE cTickets CURSOR FOR
|
||||||
SELECT DISTINCT t.id
|
SELECT DISTINCT t.id
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
LEFT JOIN tItemCalc tic ON tic.id = t.id
|
LEFT JOIN tItems ti ON ti.id = t.id
|
||||||
WHERE t.refFk IS NULL
|
WHERE t.refFk IS NULL
|
||||||
AND ((vScope = 'client' AND t.clientFk = vId)
|
AND ((vScope = 'client' AND t.clientFk = vId)
|
||||||
OR (vScope = 'address' AND t.addressFk = vId)
|
OR (vScope = 'address' AND t.addressFk = vId)
|
||||||
OR (vScope = 'item' AND tic.id)
|
OR (vScope = 'item' AND ti.id)
|
||||||
);
|
);
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tItemCalc
|
CREATE OR REPLACE TEMPORARY TABLE tItems
|
||||||
SELECT DISTINCT t.id
|
SELECT DISTINCT t.id
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
JOIN sale s ON s.ticketFk = t.id
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
|
@ -46,6 +46,6 @@ BEGIN
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE cTickets;
|
CLOSE cTickets;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tItemCalc;
|
DROP TEMPORARY TABLE tItems;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
Loading…
Reference in New Issue