Datatype Default Values

This topic provides information about datatype default values that can be set for mobile business object (MBO) attributes and parameters.

You can provide a default value for attributes and parameters that are compatible with their datatype (and used by the device application to pass to the MBO), where ever you specify a datatype (Properties view, Preview dialog, and so on).
Note: When possible, the default value is retrieved with an appropriate value from the data source when you bind to the data source, which you can then modify.

NULL and empty default values

It is important to understand the differences between the default values NULL and no default (leaving the default value empty):
  • NULL – not all datatypes support NULL as a value (int, decimal, double, float, and so on). After an MBO is created, NULL may be an available default value, but should not be selected if NULL is invalid for that datatype. If NULL is selected, and is invalid for the datatype, errors occur either when you deploy the MBO to Unwired Server, or when a device application interacts with the deployed MBO. These examples illustrate how a device application behaves when an MBO contains a synchronization parameter equal to NULL:
    • Where NULL is supported – the device application receives the rows where the attribute in the MBO is NULL. If a synchronization/load parameter is NULL, then data refresh is performed using the value NULL.
    • Where NULL is not supported – if associating synchronization parameter X with attribute X, the download cursor is similar to:
      select ... from my_table t where t.last_modified >= ... and t.x >= :X
      If X is NULL, no rows are returned, since (t.x >= :X) is false in the database if X is NULL.
  • empty default value – an empty string is not the same as no default. For string and binary datatypes, an empty string is a valid default value. For other datatypes, an empty string is invalid and generates an error.

The default value is set according to the nullability and datatype of the argument, synchronization parameter, or personalization key. For nullable types, the initial default value is set to NULL, for non-nullable types, a valid value is set according to the datatype (for example, string "", boolean "false", decimal "0", integer "0", float "0", and so on).

The default datatype length, if you do not specify one, is:
  • string – 300
  • binary – 32767

Default values for Adaptive Server Anywhere uniqueidentifiers

Keep these points in mind when working with Adaptive Server Anywhere uniqueidentifiers:
  1. Uniqueidentifiers are treated as binary datatypes in Unwired WorkSpace. If the enterprise information system (EIS) on which the uniqueidentifier resides:
    • Accepts NULL as a valid value, you can set the default value to NULL.
    • Does not accept NULL as a valid value, you need to set the correct default value. By default Unwired WorkSpace uses an empty string as the default value for binary datatypes.
  2. To avoid entering values for the UNIQUEIDENTIFIER columns during insert operations, modify the default SQL definition as this example illustrates:
    1. Create an Adaptive Server Anywhere table with SQL:
      CREATE TABLE "dba"."YorkTable" ( 
      "UniqueColumn" UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID(), 
      "Characters" VARCHAR(10) NOT NULL, 
      ) 
      IN SYSTEM 
      ; 
      ALTER TABLE "dba"."YorkTable" 
      ADD CONSTRAINT "ASA126" PRIMARY KEY NONCLUSTERED ("UniqueColumn") 
      ;
    2. Drag-and-drop the table to create the new MBO.
      The auto-generated Create operation SQL is:
      "INSERT INTO sampledb.dba.YorkTable (UniqueColumn, Characters) VALUES 
      (:UniqueColumn, :Characters)"
    3. To avoid entering values for the UNIQUEIDENTIFIER column during insert operations, change the SQL definition to:
      "INSERT INTO sampledb.dba.YorkTable (Characters) VALUES (:Characters)"