I am getting a message from MySQL Workbench that makes no sense to me.
SELECT update_customers_groups(1) LIMIT 0, 1000 Error Code: 1305. FUNCTION ph_digistore.update_customers_groups does not exist
The code below is the entirety and should work as far as I can tell.
This also pops up but, should work.
CREATE FUNCTION update_customers_groups() RETURNS INTEGER MODIFIES SQL DATA BEGIN DECLARE email_todo VARCHAR(255); DECLARE my_cursor CURSOR FOR SELECT email FROM wholesale_import_table; OPEN my_cursor; loopty:REPEAT FETCH my_cursor INTO email_todo; UPDATE ds_customers SET pgID = 1 WHERE ds_customers.cEmail = @email_todo; UNTIL done END REPEAT loopty; CLOSE my_cursor; RETURN 0; END; Error Code: 1418. This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
Yeah, if the FUNCTION errors on creation, the first error will be created too. Just what is wrong? I consulted from many sources on the net for examples.
Code:
DELIMITER ;
USE ph_digistore;
DROP FUNCTION IF EXISTS update_customers_groups;
DELIMITER $$
CREATE FUNCTION update_customers_groups() RETURNS INTEGER MODIFIES SQL DATA
BEGIN
DECLARE email_todo VARCHAR(255);
DECLARE my_cursor CURSOR FOR
SELECT email FROM wholesale_import_table;
OPEN my_cursor;
loopty:REPEAT
FETCH my_cursor INTO email_todo;
UPDATE ds_customers
SET pgID = 1
WHERE ds_customers.cEmail = @email_todo;
UNTIL done END REPEAT loopty;
CLOSE my_cursor;
RETURN 0;
END;
$$
DELIMITER ;
SELECT update_customers_groups();