Please enable JavaScript to view this site.

ESL Documentation

Compiling a SAM in DB/Assist generates ESL action routines for each valid SQL statement in the SAM These action routines consist of a combination of ESL programming statements and calls to EDB2.DLL (For complete information about the EDB2 Service and Runtime commands, refer to ESL Database 2 Support.)

The following table summarizes the ESL action routines that DB/Assist generates for each type of SQL statement, where StatementName represents the name of the statement.

Statement Type

Generated Action Routines

SELECT (multi-row)

OPEN_StatementName

FETCH_StatementName

CLOSE_StatementName

SELECT (single-row)

EXECUTE_StatementName

UPDATE (searched and positioned)

EXECUTE_StatementName

DELETE (searched and  positioned)

EXECUTE_StatementName

INSERT

EXECUTE_StatementName

Other

EXECUTE_StatementName

If you accept the default WHENEVER processing when you compile a SAM DB/Assist calls an error handling routine named EDB2WheneverError as the default action for the SQLERROR condition.

The code for EDB2WheneverError is included in the EDB2.INC file supplied with DB/Assist. It is then called from each DB/Assist­generated action routine if an error is found.

For a more detailed description of the EDB2WheneverError routine and how DB/Assist uses it during default WHENEVER processing, see Setting Code Generation Options for a SAM.

To generate code for a multi-row SELECT statement, which retrieves a set of rows from the database, DB/Assist translates it into four cursor-based statements. Together, these statements execute the SELECT statement in a cursor-oriented fashion.

The cursor-based statements and corresponding action routines for a multi-row SELECT, statement are as follows. In all of the action routines, StatementName represents the name of the SQL statement in DB/Assist.

DECLARE CURSOR statement, which defines a cursor. DB/Assist generates no code for this statement.

OPEN statement, which opens a cursor so it can fetch rows from the result table. DB/Assist generates the OPEN_StatementName action routine for this statement.

FETCH statement, which positions the cursor on the next row of the result table, fetches a single row of data, and assigns the values of that row to ESL host variables. DB/Assist generates the FETCH_StatementName action routine for this statement.

CLOSE statement, which closes the cursor. DB/Assist generates the CLOSE_StatementName action routine for this statement.

DB/Assist generates a single action routine named EXECUTE_StatementName for the following SQL statement types:

Single-row SELECT

Searched and positioned UPDATE

Searched and positioned DELETE

INSERT

Other

This action routine executes the precompiled SQL statement as a single unit of work.