Created
November 26, 2021 10:09
-
-
Save gonzaleztroyano/ef8dd3e4a562428227ca97706e0b444b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELIMITER ## | |
CREATE PROCEDURE ComprobarClientes() | |
BEGIN | |
DECLARE C1 CURSOR FOR | |
SELECT pedidos.cli_no,count(*) | |
FROM pedidos,clientes | |
WHERE pedidos.cli_no = clientes.cli_no | |
AND (clientes.localidad = 'SEVILLA' OR clientes.localidad = 'CADIZ') | |
AND (pedidos.producto_no BETWEEN 10 AND 30) | |
GROUP BY cli_no; | |
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' set lfinalizado = TRUE; | |
SELECT valor INTO cantidad FROM Ofertas where idOfertas=1; | |
OPEN C1; | |
c1_loop: LOOP | |
FETCH c1 INTO clientes,pedidos; | |
IF (lfinalizado) | |
THEN LEAVE c1_loop; END IF; | |
UPDATE clientes SET haber= haber +(cantidad*pedidos) | |
WHERE clientes.cli_no = cliente; | |
END LOOP c1_loop; | |
CLOSE c1; | |
END;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment