ciao!
avrei la necessità di settare il valore iniziale di AUTO_INCREMENT di una tabella in maniera dinamica.
ho provato a creare questa stored procedure:
codice:
DELIMITER //
DROP PROCEDURE IF EXISTS set_articoli_ecomm_auto_incr //
CREATE PROCEDURE set_articoli_ecomm_auto_incr()
NO SQL
BEGIN
DECLARE ai INT DEFAULT 0;
SET ai = (SELECT MAX(product_id) + 1 FROM oc_product);
ALTER TABLE articoli_ecommerce
AUTO_INCREMENT = ai;
END
ma mi da errore:
codice:
[42000][1064] (conn=1315390) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ai; [42000][1064] You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ai; END' at line 9
come posso fare??