Data-Type for Time-Stamping

That you don’t like to answer direct questions…

i think you should forget about triggers and just set the created_on and updated_on columns in your INSERT and UPDATE statements

:slight_smile:

The auditors must love you!!

Can you please answer this question since I seem to have misunderstodd your stance on Nulls and Empty Strings…

“Why is it that you find Zero-Length Strings to be even worse than Nulls??”

TomTees

Nothing is ever easy… is it?!

Based on what you pasted from the manual, let’s focus for a moment on:

  • created_on
  • updated_on

Let’s say that when a record is first created, I want “created_on” and “updated_on” to automatically get a system time-stamp.

And then when a record is updated, I want “updated_on” to automatically get a system time-stamp.

I know I read somewhere on the Internet, that there was some way to trick MySQL to accomplish what I want above without having to use triggers…

Does that ring any bells, r937?

TomTees

years of experience has given me a dislike for empty strings, as they are more awkward to deal with in SQL

besides, zero-length strings don’t work for DATE or DATETIME columns

:smiley:

Here is another article that is pretty close to what I remember, however the article I would like to find did a much more thorough job of describing this and several other hacks to get different desired outcomes.

Comments anyone?

TomTees

I know I saved the blog article, unfortunately it is on one of my computers in storage?! :confused:

The trick involved using Nulls to allow you to get the TIMESTAMP to automatically update two columns.

This link sorta coveres what I remember, but the author isn’t very detailed and appears to have left out basic syntax in his CREATE TABLE statement.

Does that set off any lightbulbs?

TomTees