Add User-Defined Methods With SQL Predicates
After specifying that you want to add or modify a user-defined method with an SQL
predicate (see Add User-Defined Methods or Modify User-Defined Methods on how to do this), you perform the
following steps in the Add SQL Predicate notebook:
- Type the name of the method in the Method Name entry field.
- On the SQL Predicate page, to help you construct the SQL predicate, the first part of
the SQL statement from the mapping is shown above the SQL Predicate entry field. To enter
the SQL predicate, type the SQL predicate in the SQL Predicate edit box.
For example, to predefine the query of retrieving all CARs that are of a certain color and
price over $10,000, type the following SQL:
WHERE COLOR=? AND PRICE>10000
- Click Validate. A database connection is required for validation. Each
parameter (indicated by question marks in the SQL Predicate) is mapped to a parameter and
a default C++ type. To change the C++ type mapping, go to the Parameter page.
Warning!
If you are using DB2, the following lines must be in the DB2CLI.INI file in the
SQLLIB directory, or else the validate action will return without an error message
regardless of the SQL statement's actual validity:
[common]
DEFERREDPREPARE=0
- Enter a Display Name for the method. This name can contain double-byte
characters and is used instead of the Method Name by builders such as the
Visual Builder. By default, this is the same as Method Name.
- The Parameter page shows the default mapping of SQL parameters to C++ parameters. If the
Validate action was unable to determine the SQL type of a parameter, there will be an
"X" next to the parameter name in the list box. You must select an SQL type for
the parameter by doing the following steps:
- Select the parameter in the Parameters list box.
- Select the correct SQL type for the parameter in the SQL Type drop-down
list.
- Click the Modify button. The "X" will change to a check-mark.
To change the default mapping of parameters to C++ types, do the following steps for
each parameter:
- Select the parameter in from the Parameters list box.
- If desired, change the parameter's name in the Name field.
- Select the desired C++ type from the Type drop-down list, which
contains only appropriate C++ types.
- Click the Modify button.
- On the Comment page, enter a comment for the method. This comment will be added to the
generated code for the method.
- Click OK to close the window and the method is added to the method's
container in the Manager Methods window.

User-Defined Methods

Modify User-Defined Methods
Copy User-Defined Methods
Delete User-Defined Methods

Sample: Create and Use a User-Defined Method With
SQL Predicate