MySQL Update Procedure

0
  • Create a procedure to update the sale price of the products so that:
  • a. If the selling price is lower than the average, the 10% selling price

    b. If the selling price is higher than the average it increases by 5%

    The procedure has to receive the co-product of the products.

    Show a table with the following columns on the screen: codigoproducto, precioventa before updating and precioventa after update it.

    I have tried it in this way but the Price displayed is 0 ... Any idea how to do it? Thank you very much in advance.

    drop procedure if exists procedimiento1;
    
    DELIMITER //
    
    create procedure procedimiento1 (in codproducto int(5))
    
    begin
    
    update productos 
        set PrecioVenta= case 
            when PrecioVenta<(select avg(PrecioVenta)) then PrecioVenta+(PrecioVenta*0.10)
            when PrecioVenta>(select avg(PrecioVenta)) then PrecioVenta+(PrecioVenta*0.05)
        end
        where CodigoProducto=codproducto;
    
    select CodigoProducto, PrecioVenta from productos where CodigoProducto=codproducto;
    
    end//
    
    DELIMITER //
    
    call procedimiento1 (11679);
    
        
    asked by 06.05.2018 в 19:51
    source

    0 answers