Could you please help me with the following procedure in mysql? ... The following procedure is in sqlserver. I would appreciate if you would indicate what it would be like with your syntax. I would appreciate your help please, I am suffering days ago:
CREATE PROCEDURE REGISTRARVENTA(
@idoperacion INT ,
@id_producto INT,
@fecha DATE,
@cantidad DECIMAL(7,2),
@estado VARCHAR(25),
@precio DECIMAL(7,2),
@stock DECIMAL(7,2),
@venta DECIMAL(7,2),
@MENSAJE VARCHAR(50) OUTPUT)
AS
BEGIN
IF(EXISTS(SELECT * FROM operacion WHERE idoperacion =@idoperacion))
SET @MENSAJE ='VENTA YA EXISTE'
ELSE
IF(EXISTS(SELECT * FROM producto WHERE STOCK<@CANTIDAD))
SET @MENSAJE ='NO HAY SUFICIENTE STOCK'
BEGIN
INSERT operacion VALUES(@id_producto , @fecha , @cantidad, @estado, @precio, @stock )
UPDATE producto SET STOCK =STOCK - @CANTIDAD WHERE id_producto=@id_producto
SET @MENSAJE ='VENTA REGISTRADA CORRECTAMENTE'
END
END
go