Re: [Q] Getting default value into DATETIME column
Posted in 1997
Topics: Stored Procedures & SPL, Platform-Specific Issues
titan wrote: } } Environment: RS6k F40, AIX 4.1.5, Informix SE 7.1 using Db-access. } } Hi, } } Can anyone suggest why the following code doesn't work as expected ? The } default value (as I see it) should contain the exact time (to the second } anyway) but actually shows 00:00. I've checked the FAQs and _have_ RTFM and } have found nothing to suggest that it should fail. The code was not } executed at midnight, BTW :-) } } <input> } create table activitylog } ( } actid serial, } acttask int, } acttime datetime year to second default current year to second, } actstaff int } ); } insert into activitylog(acttask,actstaff) values(19,1); } select * from activitylog; } <output> } actid actstaff acttime acttask } } 1 1 1997-02-07 00:00:00 19 } } TIA } } Ian Bishrey Hi, Ian I think this is related to your default 'CURRENT'. 'Current' function will be excuted only once, that is, when the table was created. It will always uses the value when the table is created. I remember there are some discussion about using 'current' in stored procedure, you can't use it to create a time stamp. Look at 'Informix Guide to SQL' Reference Dec. 1991 pp 7-363. This may help you. The solution is not using default in your table design. Instead you can define the column as: acctime datetime year to second; and in your sql statement, say 'insert into activitylog(acttask, acctime, actstaff) values(19, CURRENT, 1)' HTH Weimin Yang Aerotek Inc.