Support for Non-Nullable Columns with Default Values

Often tables are defined with one or more columns that are not nullable, but have default values assigned. This is often used in situations where a column is a primary key column, and so cannot be nullable, but frequently has one particular value (other fields in the primary key satisfy the uniqueness requirements).

If you use the default add method that Data Access Builder generates to add a row, you must provide a non-null value for this type of column (otherwise, an exception is thrown), which defeats the purpose of having default values. So instead of using the default add method, define your own method for adding rows with default field values.

To define this type of method, do the following steps:

  1. Select Methods from the mapping icon's popup menu.
  2. Select the add method in the top list box.
  3. Click Copy. A method called add1 will be added to the list box. Select it.
  4. Click Modify to launch the dialog for modifying the method.
  5. Change the method name to something meaningful, such as "addUsingDefaults".
  6. Modify the add method's SQL to provide default values for columns that require them.
  7. Change the settings on the following pages to reflect the changes made to the SQL query, and add a comment to describe the method (see information on Modifying User-Defined Methods in the related topics, below).
  8. Click OK to exit the Modify notebook.

Use the method that is generated to add rows without having to specify attribute values for non-nullable columns that have default values.



User-Defined Methods


Add User-Defined Methods with Customized SQL Statements
Modify User-Defined Methods