views:

35

answers:

1

Hi Friends,
I need to develop a SQL Procedure,i am having 2 table one,with following details
userid
h1
h2
h3
h4
h5
h6
h7
date

and another table with following details
useid
per

why i need a procedure,because, the data to the first table is of follows
userid h1 h2 h3 h4 h5 h6 h7 date
1 p p p p p p p 2010-10-10
while data is updated in the table like new insertion or updation on the table the value in the table 2 should be updated
consider value of table2 is
userid per
1 50
it should be updated, the formula for update is (no of workhours-total hours end)/total no of work hours

how can i do this in MySQL,and how can i use the procedure in PHP?

A: 

you can use trigger in MySQL instead of procedure. The trigger will be called after insert or update action. In my experience, I only use store procedure with some complex database manipulation or make a transaction.

coolkid
one more reason to use trigger here because if you forget to use the store procedure when insert or update, MySQL not automatically update other table for you. However with trigger, it's nice to do it automatically. :)
coolkid
can u gave me an example?
Alex Mathew
example about what? trigger or store procedure? There are some example in MySQL website :)
coolkid