Frwrdnvrbckwrds
Frwrdnvrbckwrds

Reputation: 23

How do I prevent a prepared statement from updating TIMESTAMP column?

I have a TIMESTAMP column in my table that stores the registration date of a user and when I log out from my Java application, I have a prepared statement REPLACE query update everything except the TIMESTAMP. However, the default value of the TIMESTAMP is CURRENT_TIMESTAMP which makes it set it to the current time which I don't want. If I set the default value to null it will save as NULL, and if I don't set a default value it will throw an SQL exception.

How do I make a prepared statement ignore that column completely?

Upvotes: 2

Views: 215

Answers (1)

Borealid
Borealid

Reputation: 98559

If you want the timestamp to keep its current value, you must either use an UPDATE (instead of a REPLACE) or have the REPLACE trigger do a read-modify-write, grabbing the current value of the timestamp and then writing it back to the new record.

Upvotes: 2

Related Questions