Hi all is it possible to insert the date automatically on a record creation or update in mysql , instead of passing the values on a insert would this some sort of server type thing eg stored procedure ?
I didn't get exectly. can you expalin it. yes you can insert data automatically. plz clear give exect info... Thank Sam
for example could a record have a default entry as date() every time the recored was updated the date would change or if a new row was created the date would be todays date by default instead of me passing the value from a form with a date string
I am not sure you can use that I use it in following manner: insert into table (col1, updated_date) values ('value1', now()); Code (markup):
oh well here we go its a no no 10.1.4. Data Type Default Values The DEFAULT value clause in a data type specification indicates a default value for a column. With one exception, the default value must be a constant; it cannot be a function or an expression. This means, for example, that you cannot set the default for a date column to be the value of a function such as NOW() or CURRENT_DATE. The exception is that you can specify CURRENT_TIMESTAMP as the default for a TIMESTAMP column. See Section 10.3.1.1, “TIMESTAMP Propertiesâ€.
in MSSQL, set the date column to NOT NULL and default value to getdate() NOt sure if their is a translation in MySQL for something like that.
if you use mysql5 you can place a code into trigger, in your case assign it at before insert and before update