To set non-default values for code generation options that apply to the entire SAM, you must complete the Code Generation Options dialog box, as shown below.
Code Generation Options Dialog Box
To display the Code Generation Options dialog box, select SQL Access Module Ø Options Ø Code generation.
Default Values
The Code Generation Options dialog box specifies the following types of options that apply to the entire SAM
•Actions to take in your ESL program when it finds certain SQL exception conditions. This is referred to as default WHENEVER processing.
•Whether DB/Assist should add the SAM name to each ESL action routine in that SAM.
The default WHENEVER processing options specify the actions that your ESL program should take if it finds any of the following SQL exception conditions when executing the generated code for a SQL statement:
•SQL system error (SQLERROR)
•SQL system warning (SQLWARNING)
•No rows found (SQLNOTFOUND)
You can specify either of the following actions if your program finds one of these conditions:
•Check the Continue box to execute the next sequential instruction in your ESL program. Essentially, checking Continue directs your program to ignore the exception condition.
•Pass program control to the ESL action routine you specify in the Action entry field.
The Default WHENEVER Processing options apply to all statements in your SAM unless you override them for a particular statement by specifying different options in the Code Generation - Statement Options dialog box (For information about completing the Code Generation - Statement Options dialog box, see Setting Code Generation Options for a Statement.)
When you compile a SAM, DB/Assist references a default error handling action routine named EDB2WheneverError. The code for EDB2WheneverError is included in the EDB2.INC file supplied with DB/Assist. DB/Assist uses this routine as the default action for the SQLERROR condition, unless you specify otherwise.
The EDB2WheneverError action routine does the following:
•Writes the ESL SQL Communication Area (ESQLCA) structure to the ESL errorlog. DB2 uses the ESQLCA structure to return error information to an application program
•Gets the error message from EDB2.DLL and puts it in an application-wide variable. You can use the contents of this variable in a status message in your program.
•Rolls back the database to its previously saved state. This closes the cursor for the current statement, if one was open.
For information about the code that DB/Assist references for the EDB2WheneverError action routine, see Examples of Generated ESL Code.
The Add SQL Access Module name to action routine names check box allows you to specify whether DB/Assist should add the SAM name to all action routines generated for that SAM
By default, DB/Assist does not add the SAM name to generated action routines. Action routine names consist of the prefix OPEN_ FETCH_ CLOSE_ or EXECUTE_ followed by the statement name. For example, a statement called InsertStaff generates an action routine called EXECUTE_InsertStaff.
If you check this option, DB/Assist adds the SAM name to all generated action routines in that SAM For example, if the InsertStaff statement is part of a SAM called ADMIN, checking this option generates an action routine called EXECUTE_InsertStaff_ADMIN.
If your ESL Application uses multiple SAMs, checking the Add SQL Access Module name option is useful if you want to ensure that action routine names are unique throughout the entire project. It may also be useful as a means of identifying from which SAM a particular action routine was generated.
The following table briefly describes the options in the Code Generation Options dialog box and lists their default values.
For complete information about each option, use the Help Button on the dialog to display the DB/Assist help file topic for the Code Generation options.
Option |
Description |
Default Value |
SQLERROR |
Identifies a SQL system error. |
Continue: unchecked Action: EDB2WheneverError |
SQLWARNING |
Identifies a SQL system warning. |
Continue: checked Action: none |
SQLNOTFOUND |
Identifies that no rows were found. |
Continue: checked Action: none |
Add SQL Access Module name to action routine names |
Specifies whether DB/Assist should add the SAM name to all action routines generated for that SAM. |
Unchecked |
Setting Non-Default Values
To set non-default values for code generation options that apply to all statements in the SAM, follow these steps:
1.Select SQL Access Module Ø Options Ø Code generation.
The Code Generation Options dialog box appears (as shown above).
2.Set the Default WHENEVER Processing options that you want in either of the following ways:
•Check the Continue box to execute the next sequential instruction in your program when a SQIERROR, SQLWARNING, or SQLNOTFOUND condition is found.
•Uncheck the Continue box and type an action routine name in the Action entry field. This passes program control to the specified action when a SQLERROR, SQLWARNING, or SQLNOTFOUND condition is found.
1.If desired, check the Add SQL Access Module name to action routine names check box to specify that DB/Assist should add the SAM name to all action routines generated for that SAM
2.Select the OK push button.
DB/Assist sets the selected options and applies them when you compile the SAM.
For example, below shows how you would complete the Code Generation Options dialog box to set the following options:
•Use the EDB2WheneverError action routine for the SQLERROR condition.
•Use an action routine called MyWarningRoutine for the SQLWARNING condition.
•Ignore the SQLNOTFOUND condition.
•Add the SAM name to action routine names.
Completed Code Generation Options Dialog Box