Ejryuu Posted January 27, 2010 Share Posted January 27, 2010 I am running a server with cPanel and mysql and phpmyadmin and its all uptodate. So what I am doing is I am hosting a website and they need stored PROCEDURE for there db. I have never done any thing with stored PROCEDURE so I got no idea what I am doing! I am not sure how to add or if it is even right. 'BEGIN DECLARE done INT DEFAULT 0; DECLARE raid_count_60 int; DECLARE raid_count_30 int; DECLARE individualraid int; DECLARE individualraid_30 int; DECLARE percent int; DECLARE membername varchar(100); DECLARE start_Date int; DECLARE Curr_Date int; DECLARE first_raid int; DECLARE curr1 CURSOR for SELECT member_name from eqdkp_members; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; OPEN curr1; REPEAT FETCH curr1 into membername; IF NOT done then Set Curr_Date =UNIX_TIMESTAMP(DATE_SUB(CURDATE(),INTERVAL 60 DAY)) ; Select member_firstraid into first_raid from eqdkp_members where member_name= membername; IF first_raid > Curr_Date then set Curr_Date = first_raid; END if; SELECT count(*) into raid_count_60 FROM eqdkp_raids WHERE Curr_Date <= raid_date ; select count(*) into individualraid FROM eqdkp_raids r, eqdkp_raid_attendees ra WHERE (ra.raid_id = r.raid_id) AND (ra.member_name= membername ) and Curr_Date <= raid_date ; Set Curr_Date =UNIX_TIMESTAMP(DATE_SUB(CURDATE(),INTERVAL 30 DAY)) ; IF (first_raid> Curr_Date) then set Curr_Date = first_raid; END if; SELECT count(*) into raid_count_30 FROM eqdkp_raids WHERE Curr_Date <= raid_date ; select count(*) into individualraid_30 FROM eqdkp_raids r, eqdkp_raid_attendees ra WHERE (ra.raid_id = r.raid_id) AND (ra.member_name= membername ) and Curr_Date <= raid_date ; update eqdkp_members set Raids60 =round(individualraid - raid_count_60 * 100), Raids30 =round(individualraid_30 - raid_count_30 * 100) where member_name =membername; END IF; UNTIL done END repeat; CLOSE curr1; delete from report_date; -- select null; insert into report_date value (Now()); select 1 into individualraid; so what I need to know is...is that right will it work and how do I add it? Help would be nice Quote Link to comment https://forums.phpfreaks.com/topic/189985-mysql-stored-procedure/ Share on other sites More sharing options...
manwhoeatsrats Posted January 27, 2010 Share Posted January 27, 2010 I don't know much about the stored procedures, but seeing as how no reply has been made. have you chekced the new mysql manual? here is an article that might help http://www.mysql.com/news-and-events/newsletter/2004-01/a0000000297.html Quote Link to comment https://forums.phpfreaks.com/topic/189985-mysql-stored-procedure/#findComment-1002442 Share on other sites More sharing options...
Ejryuu Posted January 27, 2010 Author Share Posted January 27, 2010 I have checked it and I am at 100% loss....it gose right over my head Quote Link to comment https://forums.phpfreaks.com/topic/189985-mysql-stored-procedure/#findComment-1002524 Share on other sites More sharing options...
Mchl Posted January 27, 2010 Share Posted January 27, 2010 This code doesn't look complete to me. CREATE PROCEDURE syntax is here: http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html Quote Link to comment https://forums.phpfreaks.com/topic/189985-mysql-stored-procedure/#findComment-1002535 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.