Jump to content

Recommended Posts

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 :D

Link to comment
https://forums.phpfreaks.com/topic/189985-mysql-stored-procedure/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.