Tech Tip: Method to determine if a field's data are automatically generated
PRODUCT: 4D | VERSION: 14.3 | PLATFORM: Mac & Win
Published On: February 5, 2015
Below are a couple of methods to determine if a field's data are automatically generated upon creation.
GetAutoUUID determines if the field automatically generates UUID values.
GetAutoIncrement determines if the field automatically generates Incrementing values.
The commands are simple to use with the following example:
Table 1 - Field 1 has the AutoIncrement property set
Table 1 - Field 2 has the AutoUUID property set
Table 1 - Field 3 has no automated property set
GetAutoUUID determines if the field automatically generates UUID values.
//Method: GetAutoUUID //Parameters: // $1 - Table number // $2 - Field number // $0 Boolean Returns: // True - If field automatically generates a UUID value // False - If field does not automatically generates a UUID value //----------------------------------------------------------------------- C_LONGINT($1;$table_id_l) C_LONGINT($2;$column_id_l) C_BOOLEAN($0;$autoGen_b) If (Count parameters>=2) $table_id_l:=$1 $column_id_l:=$2 Begin SQL SELECT AUTOGENERATE FROM _USER_COLUMNS WHERE TABLE_ID = :$table_id_l AND COLUMN_ID = :$column_id_l INTO :$autoGen_b; End SQL $0:=$autoGen_b End if |
GetAutoIncrement determines if the field automatically generates Incrementing values.
//Method: GetAutoIncrement //Parameters: // $1 - Table number // $2 - Field number // $0 Boolean Returns: // True - If field generates automaticly incrementing values // False - If field does not generates automaticly incrementing values //----------------------------------------------------------------------- C_LONGINT($1;$table_id_l) C_LONGINT($2;$column_id_l) C_BOOLEAN($0;$autoInc_b) If (Count parameters>=2) $table_id_l:=$1 $column_id_l:=$2 Begin SQL SELECT AUTOINCREMENT FROM _USER_COLUMNS WHERE TABLE_ID = :$table_id_l AND COLUMN_ID = :$column_id_l INTO :$autoInc_b; End SQL $0:=$autoInc_b End if |
The commands are simple to use with the following example:
Table 1 - Field 1 has the AutoIncrement property set
Table 1 - Field 2 has the AutoUUID property set
Table 1 - Field 3 has no automated property set
C_BOOLEAN($check_b) $check_b:=GetAutoUUID(1;1) //$check_b = False $check_b:=GetAutoUUID(1;2) //$check_b = True $check_b:=GetAutoUUID(1;3) //$check_b = False $check_b:=GetAutoIncrement(1;1) //$check_b = True $check_b:=GetAutoIncrement(1;2) //$check_b = False $check_b:=GetAutoIncrement(1;3) //$check_b = False |