Ciao ragazzi,
ho scritto questa piccola funzione mysql che dovrebbe inserire la stessa data su piu record.
sostanzialmente faccio due select, in base a una condizione, scrivendo la soluzione in una variabile. Il problema è che la prima select funziona e mi salva il count() nella variabile indicata, la seconda non ne vuole proprio sapere e non riesco a capire dove sbaglio.codice:-- -------------------------------------------------------------------------------- -- Routine DDL -- Note: comments before and after the routine body will not be stored by the server -- -------------------------------------------------------------------------------- DELIMITER $$ CREATE DEFINER=`root`@`localhost` FUNCTION `insertDataCarrello`(idCarrello varchar(45), idUtente varchar(20)) RETURNS varchar(45) CHARSET utf8 BEGIN DECLARE total_cart INT DEFAULT 0; DECLARE dataCart varchar(45) default current_timestamp; DECLARE dataCart2 datetime; select count(id_carrello) INTO total_cart from carrello where id_utente=idUtente and pagato = 'false'; IF total_cart > 1 THEN select distinct c.date INTO @dataCart2 from carrello c where c.id_carrello='3_134'; RETURN @dataCart2; END IF; RETURN @dataCart; END
![]()
datemi una mano![]()
![]()

Rispondi quotando