store procedure check expirydate

Discussion in 'MySQL' started by kumiko, Mar 22, 2008.

  1. #1
    halo there, i need some help on writing store procedure.
    i have 1 table which store the productid,productname,customerid expirydate of the product, remindersent.
    customer table---> cusotmerid, customeremail
    wat i wan to do is, i wan to check the expiry date for each customer 's products .
    if the date diff between expirydate and today is 30days, then send a reminder to the customer and update the remindersent to 1. if the date diff expirydate and today is 14days, then send a reminder to the customer and update the remindersent to 2... how i write tis in store procedure?
    plz guide me on how to write it. i know the basic for the store procedure, select, update, insert and delete only.thank you.hope can hear frm u all as soon.....coz urgent..plz help.
     
    kumiko, Mar 22, 2008 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    you will need to run a cron on server and setting up a cron is easy from cpanel of webserver.

    Before you setup a cron make a php file which checks the expired products and delete them


    Set that php program as cron

    Regards

    Alex
     
    kmap, Mar 23, 2008 IP
  3. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It depends what db you are using. If you have SQL Server (not express) then you can use SQLAgent to schedule to job to run.

    Dont know if MySQL has an equiv but as above, if your using Apache then a cron job is an easy one. If your using IIS and SQL Server Express then your options are very limited as neither have built in options for reliably timed jobs and it is generally easiest to write a hidden page to do the necessary and then write a small app to sit on your own PC that simply calls that page at the alloted time.
     
    AstarothSolutions, Mar 25, 2008 IP