"complex"

5

Hello.

I'm learning procedures and I have a question:

DELIMITER $$

CREATE PROCEDURE 'atualiza_telefone' (IN telefone INT)
BEGIN  

IF (telefone IS NULL) THEN
SELECT * FROM cliente; 

ELSE UPDATE cliente
SET telefone = "4444-4444"
WHERE seg_nome = 'Binatti';
END IF;

END $$

DELIMITER ;

I would like, if the phone is updated, put in to make a SELECT * FROM cliente , to show that the phone has been updated.

Can anyone help me? Thanks!

    
asked by anonymous 28.03.2016 / 20:52

1 answer

0

I'm going here not exactly as an answer, but for formatting.

By default, PROCEDURES should not return values, but if you do this you have to select it in the final statement.

See if this works.

Now if your intention is;

  

I wanted to understand this stop of two instructions in a single clause,   Do you understand?

You need to explain what you want better.

DELIMITER $$

CREATE PROCEDURE 'atualiza_telefone' (IN telefone INT)
BEGIN  

    IF (telefone IS NOT NULL) THEN

        UPDATE cliente
        SET telefone = "4444-4444"
        WHERE seg_nome = 'Binatti';

    ELSE 

        SELECT * FROM cliente; 

    END IF;


END $$

DELIMITER ;
    
29.03.2016 / 16:21