1

So I have this stored function added in mysql workbench:

CREATE FUNCTION `getfullAdd` (id INT unsigned)
RETURNS VARCHAR(160)
CHARACTER SET utf8
COMMENT 'function that returns all addresses with character string when you enter customer number'
DETERMINISTIC
READS SQL DATA
BEGIN
DECLARE addfound VARCHAR(160) CHARACTER SET utf8;
SELECT CONCAT_WS(', ', addr01, addr02) INTO addfound FROM dtb_customer WHERE customer_id=id;
RETURN addfound;
END

I'm bit new to this DETERMINISTIC keyword.

What does it do to the function above?

If set by this keyword, does function return the same value by the same parameter?

If customer's address is changed, does this function returns different result from the same parameter?

andil01
  • 377
  • 4
  • 19
  • Possible duplicate of [Deterministic function in mysql](https://stackoverflow.com/questions/7946553/deterministic-function-in-mysql) – lamandy Dec 11 '17 at 08:59

1 Answers1

1

From the manual

"A routine is considered “deterministic” if it always produces the same result for the same input parameters, and “not deterministic” otherwise. "

https://dev.mysql.com/doc/refman/5.7/en/create-procedure.html

So your function is DETERMINISTIC as long as none of the customer id's change.

Jaydee
  • 4,138
  • 1
  • 19
  • 20