问题
I come with a question and hope to get an answer Well, my question is: Indicate the correct procedure call I wonder about the answers: b or d but I do not know if this is a good "way of thinking"
create procedure car2(out average float)
begin
select avg(cena) into average from car;
end //
a) call car2 (average);
b) call car2 (@total);
c) call car2 ();
d) Neither answer is correct
Thank you in advance for your answer and maybe explaining why this answer and not another one
回答1:
The answer a) call car2 (average);
may be both correct and incorrect, depends on the place where this statement is written. For example, if it is a statement in another SP which has the variable average
defined with correct datatype then this statement is correct.
The answer b) call car2 (@total);
is correct always.
The answer c) call car2 ();
is incorrect - MySQL does not allow to skip parameters, the error message that the parameters amount does not match the procedure definition will be generated.
So the answer d) Neither answer is correct
is incorrect.
回答2:
The correct answer is (b) call car2 (@total);
Option (a) doesn't use an @ symbol to identify a variable, and option (c) doesn't provide a variable at all.
来源:https://stackoverflow.com/questions/66016254/indicate-a-valid-procedure-call