Page 1 of 1

Default Value of a Column based on a Database Function

Posted: Sat 21 Mar 2015 15:16
by to11mtm
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?

Re: Default Value of a Column based on a Database Function

Posted: Mon 23 Mar 2015 12:47
by MariiaI
Thank you for the report on this. We will investigate the possibility to implement changes which could affect this behaviour and inform you about the results as soon as any are available.
Meanwhile, please use the workaround that you've described.

Re: Default Value of a Column based on a Database Function

Posted: Thu 26 Mar 2015 14:08
by MariiaI
The behaviour is changed: now the default values are not set for string properties, that correspond to fields with the default values like expressions.
New build of dotConnect for Oracle 8.4.379 is available for download!
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=1&t=31498.

JIC: turn on the Detect function-based column default value option in Model Settings so that the corresponding property has Store Generated = Identity.