0

I have parent table let say CAR, and its multiple props/records in child table let say CAR_PROPS.

Now CAR has modified_date column like

  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

Since CAR along with its all properties are treated as single object, we are expecting any change on its props (CAR_PROPS) alone should also update the parent table (CAR's) modified_date.

However this is not real since CAR doest really updated hence modified_date is not changed when any of its child record got updated.

To simplify i want sql column modified_date to be updated, though i dont have anything/anyother column to update in the row.

How to solve this problem?

NOTE: I dont want to pass the modified_date from server, just want go with DB timestamp.

0

Provided you have no control how the CAR_PROPS gets updated (i.e. you didn't write a suitable stored procedure to do what you need to do) then I can only think of implementing a trigger on the CAR_PROPS table so that it goes off and updates the dateModified for the car whose props were edited.

if you do have control, and you can tell me people to update things in a particular way and you can write and use a stored procedure for this then that's what I would do.

I hope this makes sense,

B

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.