This commit is contained in:
parent
a995d80b46
commit
d0f1362f85
|
@ -16,16 +16,16 @@ BEGIN
|
|||
DECLARE cTickets CURSOR FOR
|
||||
SELECT DISTINCT t.id
|
||||
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
|
||||
AND ((vScope = 'client' AND t.clientFk = 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;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tItemCalc
|
||||
CREATE OR REPLACE TEMPORARY TABLE tItems
|
||||
SELECT DISTINCT t.id
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
|
@ -46,6 +46,6 @@ BEGIN
|
|||
END LOOP;
|
||||
CLOSE cTickets;
|
||||
|
||||
DROP TEMPORARY TABLE tItemCalc;
|
||||
DROP TEMPORARY TABLE tItems;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
Loading…
Reference in New Issue