Comments on: Business Rule: Only One per Day, but keep the time Friends of Oracle and Java Sat, 25 Apr 2015 11:36:47 +0000 hourly 1 By: Alex Tue, 20 Sep 2011 08:49:39 +0000 @Florence,
The business rule that is supposed to be enforced requires a single record per day, so only one record is allowed for August 24. However the customer also wants to know when (at what time)  this record was entered.
The constraint must limit only one record per day. But when querying the data, the time-component of the DATE column must still be there.
Does this clarify things?
(sorry to comment so late, your comment was only public just now)

By: Sebastian Fri, 16 Sep 2011 14:10:37 +0000 Pretty amazing stuff.
Thanks for sharing.

By: Alex Thu, 08 Sep 2011 11:43:20 +0000 The objective is to record a record per ID, per Day, and still keep the time component.
When you use TRUNC (SYSDATE), you will loose the time component (because it will be set to midnight).
Even with a TIMESTAMP, you will loose the time component when you TRUNC it.
Guess I should have explained the requirement more clearly. Thank you for your comment.

By: Marco Gralike Thu, 08 Sep 2011 10:47:54 +0000 Can the one second issue be avoided via using timestamp…?

By: Florence M. Cano Fri, 26 Aug 2011 05:14:48 +0000 The codes are are quite complicated. As i can see,the  the output in the above script, only one record is inserted into the table, the other attempt yields an exception.