f2s_table_constraint_state¶
Applies to: Oracle, MS SQL, MySql/MariaDB, PostgreSQL Drivers
Syntax
set_attribute f2s_table_constraint_state of {File} to {variable}
get_attribute f2s_table_constraint_state of {File} to {variable}
Parameter |
Description |
---|---|
File |
File is the file number {filename.File_Number) OR name of the file (filename) |
variable |
Boolean variable. If true, the filter is active, false, it is not active. Default: true |
Description
Setting this attribute turns on (true) or off (false) any additional constraints that you have added to the predefined Database SQL statement (see attribute f2s_table_constraint). Getting this attribute returns true if the additional constaints are on, false if it is not.
Examples
use for_all.pkg //needed to use the For_All/End_For_All block
String sCon
//set the constraint to only show customers that do NOT have a status of Y
set_attribute f2s_table_constraint of Customer to (SFormat("AND [%1].[%2] <> '%3'", "Customer", "Status", "Y"))
get_attribute f2s_table_constratint of Customer to sCon
Showln "Show only inactive customers"
Showln sCon
For_All Customer by Index.1 Do
Showln (Customer.Name+" "+Customer.Status)
End_For_All
Showln "********"
Showln "Show All Customers"
//set the attribute f2s_table_constraint_state to false to ignore the added constraint
set_attribute f2s_table_constraint_state of Customer to false
For_All Customer by Index.1 Do
Showln (Customer.Name+" "+Customer.Status)
End_For_All
In this example, a constraint is added to the predefined Customer SQL statement to only show those customers that are not active (Customer.Status<>’Y’). As a result, when looping through the Customer records (For_All/End_For_All) only the inactive customers are listed. Subsequently, the f2s_table_constraint_state is set to false. Now, all the customers are listed.
Related Attributes
Replaces the command SQL_CONSTRAINT. Note: SQL_CONSTRAINT uses Activate (on) or Deactivate (off) as an agrument. The attribute f2s_table_constaint_state uses a boolean.