Home » SQL & PL/SQL » SQL & PL/SQL » set default values to current epoch (2 merged) (Oracle 11.2.0.4.0 enterprise, CentOS 7.2)
set default values to current epoch (2 merged) [message #681573] Wed, 05 August 2020 03:12 Go to next message
weekend79
Messages: 198
Registered: April 2005
Location: Islamabad
Senior Member

Hi

creating a new table with 2 date columns "number(19)", one for inserted date and other for updated date,
wish to save unix 13 character long current time i.e. 1596614710000 as default value in both columns at the time of insert.
and update value of the updated column at the time of any update on row.

Can someone tell me any more efficient way then trigger for update?

thanks
Re: set default values to current epoch (2 merged) [message #681575 is a reply to message #681573] Wed, 05 August 2020 03:42 Go to previous messageGo to next message
Michel Cadot
Messages: 67369
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Do you want this as a default value or as a mandatory value?
In other words, do you want to have this value when the user gives none or do you want to force this value and forbid the user to enter another value?

[Updated on: Wed, 05 August 2020 03:45]

Report message to a moderator

Re: set default values to current epoch (2 merged) [message #681576 is a reply to message #681575] Wed, 05 August 2020 04:13 Go to previous messageGo to next message
weekend79
Messages: 198
Registered: April 2005
Location: Islamabad
Senior Member

Default
Re: set default values to current epoch (2 merged) [message #681578 is a reply to message #681576] Wed, 05 August 2020 05:43 Go to previous messageGo to next message
Michel Cadot
Messages: 67369
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Define a DEFAULT value on your table columns to fulfill INSERT requirement.
And you can't avoid a trigger for UPDATE.

Re: set default values to current epoch (2 merged) [message #681580 is a reply to message #681578] Wed, 05 August 2020 06:29 Go to previous message
weekend79
Messages: 198
Registered: April 2005
Location: Islamabad
Senior Member

thanks so trigger it is Smile
Previous Topic: Need Help in Query (merged)
Next Topic: Converting XML to JSON using Apex
Goto Forum:
  


Current Time: Fri Sep 25 02:58:29 CDT 2020