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 to, in case the phone is updated, put to make a SELECT * FROM cliente
, to show that your phone has been updated.
Can someone help me? Grateful!
More to serve your select? you will show where it was changed ?
– Marco Souza
It would serve to show the table with the new values.
– Mateus Binatti
Okay, will you do this through an application? only this parameter does proc have? if it is you don’t need the
IF (telefone IS NULL) THEN
SELECT * FROM cliente;
for you call the proc you have to pass the parameter this way will never beIS NULL
– Marco Souza
The
if
I put it just to understand how it worked. I tried to play as many things as possible. It was just to see how I would react.– Mateus Binatti
Come on, in what situation would you call one
PROCEDURE
updating if not to update the data. If you have an application updating your client, for example, you probably already have his data in your change form, when you call your Proc you inform what is being changed. So that you would return what was changed if you already have in your application?– Marco Souza
Okay, I get what you mean.
select
soon after updating the data. I wanted to understand this stop of two instructions in a single clause, you know? I don’t get your reason for being "unnecessary", but I wanted to know how it works.– Mateus Binatti
Well, by the standard
– Marco Souza