Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 4 of 4 total |
Check constraint question |
Tue, Feb 24 2009 2:20 PM | Permanent Link |
Darrell | Is there a way to have a timestamp field default to
(pseudo code) IF FIELD = NULL THEN FIELD = CURRENT-TIMESTAMP via check constraint? |
Tue, Feb 24 2009 11:34 PM | Permanent Link |
Richard Harding | Darrell,
A check constraint will generate an error if the condition is not met. It will not cause anything to be set. The TRIGGER below will do what you want. You will need another BEFORE INSERT TRIGGER also. Would setting a DEFAULT VALUE of CURRENT_TIMESTAMP for the field be a benefit? CREATE TRIGGER "BeforeUpdate" BEFORE UPDATE ON "aTable" WHEN OLDROW.EpisodeDateTime is Null BEGIN SET NEWROW.EpisodeDateTime = CURRENT_TIMESTAMP; END; Richard Harding |
Wed, Feb 25 2009 12:27 AM | Permanent Link |
darrell | Thanks Richard - exactly what i was looking for
|
Wed, Feb 25 2009 6:03 AM | Permanent Link |
Fernando Dias Team Elevate | Darrel
As Richard said, you can't do it using check constraints. You can do it using triggers or simply defining a default value for the column: ALTER TABLE <TableName> ALTER COLUMN <ColumnName> AS TIMESTAMP DEFAULT CURRENT_TIMESTAMP You can also define default values for columns interactively, using EDBManager. -- Fernando Dias [Team Elevate] |
This web page was last updated on Saturday, May 4, 2024 at 12:54 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |