db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Matrigali (JIRA)" <derby-...@db.apache.org>
Subject [jira] Updated: (DERBY-118) Allow any build-in function as default values in table create for columns
Date Wed, 17 Aug 2005 00:31:12 GMT
     [ http://issues.apache.org/jira/browse/DERBY-118?page=all ]

Mike Matrigali updated DERBY-118:
---------------------------------

      Component: SQL
    Description: 
It is ok in ij to do a   values char(current_date)   but is is not allowed to use char(current_date)
as default value for clolumns; like for example

CREATE TABLE DOSENOTWORK (num int, created_by varchar(40) default user, create_date_string
varchar(40) default char(current_date))

Request: It should be allowed to use any build-in function which return a valid type as part
of the default value spec.


There was a e-mail thread for this and the core content/answer was:

Bernd Ruehlicke wrote:
> 
> CREATE TABLE DOSENOTWORK (num int, created_by varchar(40) default 
> user, create_date_string varchar(40) default char(current_date))
> 
> give an error as below - any idea why ?!??!
> 

The rules for what is acceptable as a column default in Derby say that the only valid functions
are datetime functions. 
  The logic that enforces this can be seen in the "defaultTypeIsValid" method of the file:

./java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java

The Derby Reference Manual also states this same restriction (albeit rather briefly):

----

Column Default

For the definition of a default value, a ConstantExpression is an expression that does not
refer to any table. It can include constants, date-time special registers, current schemas,
users, and null.

----

A "date-time special register" here means a date-time function such as "date(current_date)"
in your first example. 
Since the function "char" is NOT a date-time function, it will throw an error.

I believe this restriction was put in place as part of the "DB2 compatibility" work was that
done in Cloudscape a while back.

Hope that answers your question,
Army





  was:
It is ok in ij to do a   values char(current_date)   but is is not allowed to use char(current_date)
as default value for clolumns; like for example

CREATE TABLE DOSENOTWORK (num int, created_by varchar(40) default user, create_date_string
varchar(40) default char(current_date))

Request: It should be allowed to use any build-in function which return a valid type as part
of the default value spec.


There was a e-mail thread for this and the core content/answer was:

Bernd Ruehlicke wrote:
> 
> CREATE TABLE DOSENOTWORK (num int, created_by varchar(40) default 
> user, create_date_string varchar(40) default char(current_date))
> 
> give an error as below - any idea why ?!??!
> 

The rules for what is acceptable as a column default in Derby say that the only valid functions
are datetime functions. 
  The logic that enforces this can be seen in the "defaultTypeIsValid" method of the file:

./java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java

The Derby Reference Manual also states this same restriction (albeit rather briefly):

----

Column Default

For the definition of a default value, a ConstantExpression is an expression that does not
refer to any table. It can include constants, date-time special registers, current schemas,
users, and null.

----

A "date-time special register" here means a date-time function such as "date(current_date)"
in your first example. 
Since the function "char" is NOT a date-time function, it will throw an error.

I believe this restriction was put in place as part of the "DB2 compatibility" work was that
done in Cloudscape a while back.

Hope that answers your question,
Army





    Environment: 

> Allow any build-in function as default values in table create for columns
> -------------------------------------------------------------------------
>
>          Key: DERBY-118
>          URL: http://issues.apache.org/jira/browse/DERBY-118
>      Project: Derby
>         Type: Improvement
>   Components: SQL
>     Reporter: Bernd Ruehlicke
>     Priority: Minor

>
> It is ok in ij to do a   values char(current_date)   but is is not allowed to use char(current_date)
as default value for clolumns; like for example
> CREATE TABLE DOSENOTWORK (num int, created_by varchar(40) default user, create_date_string
varchar(40) default char(current_date))
> Request: It should be allowed to use any build-in function which return a valid type
as part of the default value spec.
> There was a e-mail thread for this and the core content/answer was:
> Bernd Ruehlicke wrote:
> > 
> > CREATE TABLE DOSENOTWORK (num int, created_by varchar(40) default 
> > user, create_date_string varchar(40) default char(current_date))
> > 
> > give an error as below - any idea why ?!??!
> > 
> The rules for what is acceptable as a column default in Derby say that the only valid
functions are datetime functions. 
>   The logic that enforces this can be seen in the "defaultTypeIsValid" method of the
file:
> ./java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java
> The Derby Reference Manual also states this same restriction (albeit rather briefly):
> ----
> Column Default
> For the definition of a default value, a ConstantExpression is an expression that does
not refer to any table. It can include constants, date-time special registers, current schemas,
users, and null.
> ----
> A "date-time special register" here means a date-time function such as "date(current_date)"
in your first example. 
> Since the function "char" is NOT a date-time function, it will throw an error.
> I believe this restriction was put in place as part of the "DB2 compatibility" work was
that done in Cloudscape a while back.
> Hope that answers your question,
> Army

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


Mime
View raw message