MySQL Trigger to automatic insert based on date -


i tried following example .but doesn't insert. problem in clause??

create definer = `root`@`localhost` trigger `new` after insert on `employee` each row insert employee_log( first_name, last_name ) select first_name, last_name employee start_date = now( ) 

i'm not sure if can done triggers. can make shell script, , execute mysql commands

test.sh:

#!/bin/bash #delete today_plan mysql -e "delete today_plan" --user=user_name --password=your_password db_name #insert todays plans today_plan mysql -e "insert today_plan (pjtno, pattern, itemno, belt, kiln, qty, lnusr, distant,  remark, decww, plandate, nowdate, shipment) select pjtno, pattern, itemno, belt, kiln, qty, lnusr, distant,  remark, decww, plandate, nowdate, shipment daily_plan plandate=now()" --user=user_name --password=your_password db_name exit 

then add execution of shell script cron job in /etc/crontab like:

0  6 * * * root php /path/to/script/./test.sh 

which execute every morning @ 6:00

ps. 1 idea of how done :d

edit: or can make mysql event


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -