20 lines
693 B
SQL
20 lines
693 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_administrativeCopy`(vOriginalTicket INT, OUT vNewTicket INT)
|
|
BEGIN
|
|
|
|
INSERT INTO vn.ticket(clientFk, addressFk, shipped, warehouseFk, companyFk, landed)
|
|
SELECT t.clientFk , t.addressFk , t.shipped ,w.id, t.companyFk , t.landed
|
|
FROM vn.ticket t
|
|
JOIN vn.warehouse w ON w.name = 'INVENTARIO'
|
|
WHERE t.id = vOriginalTicket;
|
|
|
|
SELECT LAST_INSERT_ID() INTO vNewTicket;
|
|
|
|
INSERT INTO vn.sale(ticketFk, itemFk, concept, quantity, price, discount)
|
|
SELECT vNewTicket, s.itemFk , s.concept , s.quantity , s.price , s.discount
|
|
FROM vn.sale s
|
|
WHERE s.ticketFk = vOriginalTicket;
|
|
|
|
END$$
|
|
DELIMITER ;
|