default value for timestamp popup an error !!
default value for timestamp popup an error !!
Hi,
I use Firebird 2.5 64bit edition and I set the default value for a timestamp field to 'NOW' but when I call Insert or append I get error "invalid value for field1"
when I removed the default value and used the afterinsert event in Delphi I was able to use the Delphi NOW() function normally
what cause that ?
Thanks
I use Firebird 2.5 64bit edition and I set the default value for a timestamp field to 'NOW' but when I call Insert or append I get error "invalid value for field1"
when I removed the default value and used the afterinsert event in Delphi I was able to use the Delphi NOW() function normally
what cause that ?
Thanks
-
AndreyZ
-
AndreyZ
Please specify a script to create a table with a TIMESTAMP column that has the NOW default value. For example, the following code will raise the "Unknown token NOW" error:The point is that NOW is not a valid default value for a TIMESTAMP column, you should use CURRENT_TIMESTAMP instead.
Code: Select all
CREATE TABLE TEST (DT TIMESTAMP DEFAULT NOW)-
AndreyZ
You cannot use NOW as a default value of any date type neither in InterBase nor in Firebird. But you can use NOW in your queries. Here is an example:For more information, please read the following article: http://edn.embarcadero.com/article/25797 . Also you can set the DefaultExpression property of a TDateTimeField persistent field to NOW. In this case IBDAC uses the standard NOW function to fill the value for such field.
Code: Select all
Firebird:
IBCQuery.SQL.Text := 'update test set ts=''now'' where id=1'; //ts is TIMESTAMP
IBCQuery.Execute;
InterBase:
IBCQuery.SQL.Text := 'update test set dt=''now'' where id=1'; //dt is DATE
IBCQuery.Execute;