List:General Discussion« Previous MessageNext Message »
From:Jerry Schwartz Date:December 17 2010 5:09pm
Subject:RE: Access to MySQL
View as plain text  
>-----Original Message-----
>From: Shawn Green (MySQL) [mailto:shawn.l.green@stripped]
>Sent: Friday, December 17, 2010 10:35 AM
>To: Jerry Schwartz
>Cc: joao@stripped; mysql@stripped
>Subject: Re: Access to MySQL
>
>Hi Jerry,
>
>On 12/17/2010 09:34, Jerry Schwartz wrote:
>>> -----Original Message-----
>>> From: Jo?o C?ndido de Souza Neto [mailto:joao@stripped]
>>> Sent: Friday, December 17, 2010 6:11 AM
>>> To: mysql@stripped
>>> Subject: Re: Access to MySQL
>>>
>>> What about this?
>>>
>>> date_format(now(), "%Y/%m/%d")
>>>
>> [JS] I don't think you can use anything but a constant as a default value.
>>
>
>You are correct with one exception that was already mentioned earlier:
>the TIMESTAMP storage type.
>
>from http://dev.mysql.com/doc/refman/5.1/en/create-table.html
>###
>The DEFAULT clause specifies a default value for a column. With one
>exception, the default value must be a constant; it cannot be a function
>or an expression. This means, for example, that you cannot set the
>default for a date column to be the value of a function such as NOW() or
>CURRENT_DATE. The exception is that you can specify CURRENT_TIMESTAMP as
>the default for a TIMESTAMP column. See Section 10.3.1.1, "TIMESTAMP
>Properties".
>###
>
>However, nothing says you can't use a function or other computation in a
>TRIGGER to set the default value to an empty column of a new row to
>whatever you wanted it to be.
>
>http://dev.mysql.com/doc/refman/5.1/en/create-trigger.html
>
>I know it's a workaround but it will keep the default value management
>out of your application and inside the database.
>
[JS] Thanks. I did have that in the back of my mind, but to be honest I never 
used a trigger.

I'll have to think about this.


Regards,

Jerry Schwartz
Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341
E-mail: jerry@stripped
Web site: www.the-infoshop.com



>--
>Shawn Green
>MySQL Principal Technical Support Engineer
>Oracle USA, Inc.
>Office: Blountville, TN
>
>--
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe:    http://lists.mysql.com/mysql?unsub=1




Thread
Access to MySQLJerry Schwartz16 Dec
  • Re: Access to MySQLJesper Wisborg Krogh17 Dec
    • RE: Access to MySQLJerry Schwartz17 Dec
  • Re: Access to MySQLjoao17 Dec
    • RE: Access to MySQLJerry Schwartz17 Dec
      • Re: Access to MySQLMySQL)17 Dec
        • RE: Access to MySQLJerry Schwartz17 Dec