MYSQL IN FUNCTIE EN TRIGGER ONDERSTEUNEN GEEN DYNAMISCHE INSERT MAAR DE PROCEDURE KAN DYNAMISCHE INSERT ONDERSTEUNEN.
DUS KUNT U WIJZIGINGEN AANBRENGEN IN DE PROCEDURE EN PROCEDURE MAKEN IN attribute_values TABLE INSERT QUERY.
INSERT INTO attribute_values VALUES(product_id,column_name,val);
EN NADAT U GEWOON BELPROCEDURE BENT
CALL attribute_values_after_insert(2,'code',132);
DELIMITER //
drop procedure if exists attribute_values_after_insert //
CREATE PROCEDURE attribute_values_after_insert(IN product_id INT, IN
column_name VARCHAR(100), IN val VARCHAR(100))
BEGIN
SET @sql = NULL;
INSERT INTO attribute_values VALUES(product_id,column_name,val);
SELECT concat('UPDATE product_attributes SET product_attributes.', column_name, '=', val, ' WHERE id=', product_id) INTO @sql;
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET @sql = NULL;
END//
DELIMITER ;
DELIMITER //