New internal function to get the default value of the field
-----------------------------------------------------------

                 Key: CORE-3583
                 URL: http://tracker.firebirdsql.org/browse/CORE-3583
             Project: Firebird Core
          Issue Type: New Feature
          Components: Engine
    Affects Versions: 2.5.0
            Reporter: Ain Valtin
            Priority: Minor


Add internal function to query the default value of a column: 
DEFAULT_VALUE(table.field)
So one could write query like
SELECT ... WHERE DEFAULT_VALUE(field) <> field;
to get rows where value of certain field differs from the column's default 
value.

It would be nice if there is DEFAULT context available in triggers so that one 
could write
IF(NEW.Field IS DISTINCT FROM DEFAULT.Field)THEN

Feature should also be available in constraints, ie
CREATE TABLE TAB_Foo (
  fieldA  ...,
  fieldB  ...,
  CONSTRAINT C_field_AB CHECK((fieldA <> DEFAULT)OR(fieldB <> DEFAULT))
);
to ensure that either fieldA or fieldB has a different value than default.

MySQL has such a function, called DEFAUL(), see
http://dev.mysql.com/doc/refman/5.5/en/miscellaneous-functions.html#function_default
The MySQL function raises error when the field doesn't have default defined, I 
would prefer
that FB's implementation would return NULL, perhaps with addidional function
IS_DEFAULT_DEFINED() to check "the meaning of the NULL".


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to