SQLColumnDefaultValue - cDbUpdateFunctionLibrary
To set a default value for a SQL table column. The default will be used when creating records.
Type: Function
Parameters: Handle hTable, Integer iColumn String sDefaultValue
Parameter |
Description |
hTable |
A file handle to the table name. Same as the Filelist.cfg slot number. |
iColumn |
The column number to set the default value for |
sDefaultValue |
The default value to apply |
Syntax
Function SQLColumnDefaultValue Handle hTable Integer iColumn String sDefaultValue Returns Boolean
Call: |
Get SQLColumnDefaultValue TableName.File_Number iColumn "Value" to bOK |
Description
Use it to set a default value for a table column.
You can enclose the default value in square brackets []; "[getdate()]", if this is a date column or "[newid()]" for an unique record id. Note that the square brackets is not an SQL setting but a connectivity kit thing.
Alternatively you can use an ODBC escape sequence in curly brackets {}; "{fn current_date()}"
Note
If a default value has not been specified for a particular column, the default value for the corresponding data type will be used. These settings are read from the driver's .int file when the framework is initialized. Those "global" data type settings can be changed by setting any of these properties: psDriverDefaultValueASCII, psDriverDefaultValueBinary, psDriverDefaultValueDate, psDriverDefaultValueDateTime, psDriverDefaultValueNumeric or psDriverDefaultValueText. They corresponds to the driver "DF_DRIVER_DEFAULT_DEFAULT_xxx" settings.
See Also
NULL Values and Defaults for more information.
Example
Procedure OnUpdate
Boolean bOK
Get SQLColumnDefaultValue Customer.File_Number (RefTable(Customer.Status)) "1" to bOK
End_Procedure