Default Value of a Column based on a Database Function
Posted: Sat 21 Mar 2015 15:16
We are using the Devart Oracle Provider with an Oracle 10G database
Our environment uses Created/Modified rows including a 'created by' field. The 'Created by' is a default value of 'sys_context('USERENV', 'CURRENT_USER')' to track the database user that inserted the row (so if data management inserts a row instead of an application, it's tracked.)
The issue I run into is that because it is a VarChar2 field, Entity Developer brings in the default value of the column as that text, and attempts to use that text when inserting the row (This lead to amusing failures, as the field is set to VarChar2(30), but nevermind that.)
The current 'fix' I have is:
1: After the columns are brought in, clear out the 'default' value for the object in entity developer. Set the Created_By column to 'identity'
2: Go to the same column in the store. Set the Created_By column to 'identity' as well
It's a little kludgy however, as we have to remember to do this, and risk a developer accidentally re-pulling the column and breaking the changes. Is there a better way to handle this?
Our environment uses Created/Modified rows including a 'created by' field. The 'Created by' is a default value of 'sys_context('USERENV', 'CURRENT_USER')' to track the database user that inserted the row (so if data management inserts a row instead of an application, it's tracked.)
The issue I run into is that because it is a VarChar2 field, Entity Developer brings in the default value of the column as that text, and attempts to use that text when inserting the row (This lead to amusing failures, as the field is set to VarChar2(30), but nevermind that.)
The current 'fix' I have is:
1: After the columns are brought in, clear out the 'default' value for the object in entity developer. Set the Created_By column to 'identity'
2: Go to the same column in the store. Set the Created_By column to 'identity' as well
It's a little kludgy however, as we have to remember to do this, and risk a developer accidentally re-pulling the column and breaking the changes. Is there a better way to handle this?