Is there a way to loop through individual query records within a stored procedure or trigger. If I have table called client_names (id SERIAL, first name TEXT, middlename TEXT, lastname TEXT, suffix TEXT, pet_id INT, properly_trained TEXT) and I have a trigger on it, I'd like to iterate through individual query rows back at another table having a foreign key on pet_id. For example:
CREATE TRIGGER update_clients_with_week_assignment_based_on_pet_id_in_pets_table BEFORE INSERT ON client_names FOR EACH ROW BEGIN (SELECT * FROM pets;) label1: LOOP IF (pets row.pet_type) = 4 THEN SET properly_trained = 1; ITERATE label1; END IF; LEAVE label1; END LOOP label1; SET @x = p1; END Is this possible. Can you loop through the query results of a SELECT statement in a trigger, function, or procedure. Ferindo