f2s_type_override_nulls

Applies to: Oracle, MS SQL, MySql/MariaDB, PostgreSQL Drivers

Syntax

set_attribute f2s_type_override_nulls of {DriverID} {datatype} to {variable}
get_attribute f2s_type_override_nulls of {DriverID} {datatype} to {variable}

Parameter

Description

DriverID

The ID of the driver for which this applies. In most cases, you should use _f2s_ActiveDriverID.

datatype

Type of data, must be: DF_ASCII, DF_BCD, DF_BINARY or DF_DATE

variable

Boolean variable, indicates how to handle blank data. True is blank, false is however the database would normally save the value. Default value is false.

Description

Setting this attribute to true, forces blank/0 values for that data type to be stored as blank/0 instead of NULL (assuming the field allows NULL). For example, lets say the user tries to save a new record that has a string field that allows nulls and has no default value. Assume the user does not specify a value for this field. If this attribute is set to true, when the record is saved, that string value will stored as a blank string. If the attribute is set to false (the default), the value will be stored as NULL.

Getting this value returns whether or not blank/0 values are forced for values that might otherwise be NULL.

Datatypes and the values that can be forced to Blank/0 (instead of NULL):

Data Type

Database Back End

Value forced NULL

DF_ASCII and DF_TEXT

ALL

‘ ‘ (one blank space)

DF_BCD

ALL

0 (zero)

DF_DATE and DF_DATETIME

MySql

00/00/0000

DF_DATE and DF_DATETIME

Oracle and MS SQL Date

01/01/0001

DF_DATE and DF_DATETIME

PostgreSQL and MSSQL datetime

01/01/1753

Examples

get_attribute

boolean bForceBlank

get_attribute f2s_type_force_nulls of _f2s_ActiveDriverId DF_ASCII to bForceBlank

set_attribute

In this example the database backend is MS SQL and a string field that allows nulls, TextNull, has been added to the Users table in the OrderEntry example. TextNull has no default value. Therefore, when a new record is saved and TextNull is not specifically given a value, the new record will have a NULL value for TextNull. When f2s_type_override_nulls is set to true, the new record will have an blank (empty string) value.

//by default, f2s_type_override_nulls is false
Send Clear to oUsers_DD
Set Field_Changed_Value of oUsers_DD Field Users.Full_Name to "Jane Doe"
Set Field_Changed_Value of oUsers_DD Field Users.LoginName to "jdoe"
Set Field_Changed_Value of oUsers_DD Field Users.Password to "password"
Set Field_Changed_Value of oUsers_DD Field Users.Rights to 1
Send Request_Save to oUsers_DD
Send Clear to oUsers_DD

set_attribute f2s_type_override_nulls of _f2s_ActiveDriverId DF_ASCII to true
Send Clear to oUsers_DD
Set Field_Changed_Value of oUsers_DD Field Users.Full_Name to "George Doe"
Set Field_Changed_Value of oUsers_DD Field Users.LoginName to "gdoe"
Set Field_Changed_Value of oUsers_DD Field Users.Password to "password"
Set Field_Changed_Value of oUsers_DD Field Users.Rights to 1
Send Request_Save to oUsers_DD
Send Clear to oUsers_DD

The values in the database, when looking at the raw data, should be NULL for Jane Doe but blank for George Doe.

Related Attributes

  • f2s_type_force_nulls

Replaces: Commands SET_FIELDS_NOT_NULL and GET_FIELDS_NOT_NULL