A domain may have a default value. This is the value that is used whenever a user does not take specific action to set a column to a different value. For example:
•You could have a domain COUNTRY with Default Value = "United States" if the vast majority of your customers are from that country. In columns based on the domain, the value 'United States' will automatically appear, but users will be able to overwrite it if necessary. •You could have a domain with 'Y' and 'N' as allowed values, Default Value = 'N', and Display Type = Checkbox. In the user application, columns based on this domain will materialise as a checkbox that is empty by default. If it applies, the user must check it herself.
A default value for a domain must be taken from the pool of allowed values represented by the domain. It is your responsibility as a developer to make sure that the default value of a domain is actually allowed in that domain. In particular, if you enumerate allowed values for the domain, the default value MUST be one of those enumerated values.
|
You can also set a default value for an individual column. A default value set for an individual column OVERWRITES any default value set for the domain that the column is based on.
|
If your domain has a superdomain, it inherits that superdomain's default value (if the superdomain has a default value). However, if the domain has itself a different default value, this OVERWRITES the superdomain's default value.
|
In columns that have Mandatory = Yes and that are based on a domain with Display Type = Checkbox and with Allowed Values 'Y' and 'N', only 2 values are possible at RDBMS level: 'Y' and 'N'. Best practice in these cases is to set a Default Value, that is, not to leave Default Value empty. In many cases 'N' will be the most appropriate default value, but this is a matter of application-specific functionality.
In columns that have Mandatory = No and that are equally based on a domain with Display Type = Checkbox and with Allowed Values 'Y' and 'N', 3 values are possible at RDBMS level: 'Y', 'N' and the empty or NULL value. Best practice in these cases is often to leave the Default Value domain attribute empty.
|
If you want the Default Value to be the current date, or the current date and time, you must specify one of the values:
$$CURRENTDATE$$
or
$$CURRENTDATETIME$$
A new date and time value is fetched from the server each time you refer to one of these functions. A different possibility is to use
$$TRANSACTIONDATE$$
or
$$TRANSACTIONDATETIME$$
In this case, the current date and time are fetched from the server only once within a transaction. If you refer to one of these functions again within the same transaction, an identical date and time value is returned.
|
If you want the default value to be the user name of the current user, specify:
$$USER$$
You may overrule a domain default value at the column level. That is, when you specify a default value at column level, it overrules the default values of the domain on which it is based.
|
See Also
Domains
|