MySQL Forums
Forum List  »  Italian

Re: Ciclo For di access
Posted by: Michele Abbondanza
Date: September 30, 2008 04:14AM

uhm.. se ti può servire ecco un esempio di come puoi fare la procedura che fa "qualcosa" tante volte quanti sono i giorni di differenza es:

call nomePROC(20080930,20080926);
lo farà 4 volte..


DELIMITER $$

DROP PROCEDURE IF EXISTS `test`.`nomePROC` $$
CREATE PROCEDURE `nomePROC`(data1 varchar(255), data2 varchar(255))
BEGIN
DECLARE cont INT default 0;
DECLARE fine INT default 0;

SELECT DATEDIFF(STR_TO_DATE(data1,'%Y%m%d'),STR_TO_DATE(data2,'%Y%m%d')) INTO fine;

REPEAT
SET cont = cont + 1;
#qui il codice da fare per TOT volte
UNTIL cont >= fine
END REPEAT;

END $$
DELIMITER ;

Options: ReplyQuote


Subject
Views
Written By
Posted
6544
September 26, 2008 03:48AM
3553
September 29, 2008 01:55AM
3249
September 29, 2008 02:51AM
Re: Ciclo For di access
3484
September 30, 2008 04:14AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.