tags:

views:

62

answers:

1

In my table I want to set default of a column to 30 days from now. This needs to be a real, not computed column. Something like

alter table T_NAME alter column EXPIRATION set default CURRENT_TIMESTAMP + 2592000

is not valid, but you get the idea. I am sure I can do that with a before insert trigger, but I was just wondering if there is a trick for doing arithmetics in default clause that I just don't know about.

My DB is Firebird 2.1.2

+1  A: 

I don't think there is, as the Language Reference gives both for CREATE TABLE and for ALTER TABLE:

[DEFAULT {literal | NULL | USER}]

I guess the trigger is indeed your only option.

mghie
Yes, triggers are needed for this. btw, to add 30 days, the correct is current_timestamp+30
Douglas Tosi