How to make multiple UPDATES in a MySQL PROCEDURE?

0

How do I make two or more UPDATES run in the same PROCEDURE.

CREATE DEFINER = root@localhost PROCEDURE sp_anularFacturaBoleta(
    IN idFacturaBoleta VARCHAR(11)
)
BEGIN
    UPDATE detalle_factura_boleta SET cantidad = 0, precio_venta = 0, valor_venta = 0 WHERE id_factura_boleta = idFacturaBoleta;
    UPDATE factura_boleta SET subtotal = 0, igv = 0, total = 0, id_orden_pedido = '' WHERE id_factura_boleta = idFacturaBoleta;
END
    
asked by gcarlo16 18.07.2018 в 19:39
source

1 answer

0

I'll give you an example to guide you on the task you want to do

CREATE PROCEDURE update_clients(@table1_id INT, @table2_id INT, @value1 VARCHAR(20), @value2 VARCHAR(20))
AS
BEGIN
    UPDATE clients
    SET    client_name = @value1
    WHERE id = @table1_id

    UPDATE salesmen
    SET salesman_name = @value2     
    WHERE id = @table2_id
END

Where as notes within the parentheses of the SP I declare the names of the ids of the tables that I will use to make the operation of WHERE , likewise I declare the names and type of the variables that will receive the data that will be updated

Already inside the SP I declare 2 UPDATE , I hope the example is useful to guide you

    
answered by 18.07.2018 в 19:53