MySQL Forums
Forum List  »  MySQL Query Browser

Re: convert Oracle to mysql type
Posted by: irek kordirko
Date: February 28, 2012 09:25AM

pratik kanawade Wrote:
-------------------------------------------------------
>
> ORG_ID NUMBER default TO_NUMBER ( DECODE (
> SUBSTRB ( USERENV ( 'CLIENT_INFO') ,1,1 ) , '
> ',NULL,SUBSTRB ( USERENV ( 'CLIENT_INFO') ,1,10 )
> ) ),
>

Hmmm, you cannot do this in that way.
MySql allows only constants in the DEFAULT clause in the create table statement.
http://dev.mysql.com/doc/refman/5.5/en/create-table.html
Quote

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.4, “Automatic Initialization and Updating for TIMESTAMP”.

Just skip the DEFAULT clause and create the table without it.
You may also create a before insert trigger , check if this column is null, and if yes - select the default value from another table.



Edited 3 time(s). Last edit at 02/28/2012 03:20AM by irek kordirko.

Options: ReplyQuote


Subject
Written By
Posted
February 27, 2012 07:01AM
Re: convert Oracle to mysql type
February 28, 2012 09:25AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.