Differences Between Dynamic and Static ESQL
The run-time capabilities of dynamic ESQL require additional syntax and differ in functionality from static ESQL. The differences include:
Specifying SQL Statements
In static ESQL, you specify all SQL statements as part of the Progress/ESQL statement syntax, which the preprocessor converts to r-code references or hard-coded character strings for compilation at run-time. In dynamic ESQL, you specify SQL statements in SQL request strings that you can build from scratch at run time.
A request string is a C character string that contains the text of an SQL statement, but does not include an EXEC SQL prefix, a semicolon (;) statement terminator, or an embedded host variable name. (The prefix and terminator apply only to Progress/ESQL statements.) For more information, see the "Elements of Progress/ESQL" section.
The work to specify, compile, and execute SQL statements in dynamic ESQL is divided between the user, your application, and ESQL. To manage this division of labor, dynamic ESQL allows the user (or application) to specify most elements of an SQL request in the request string, while restricting other elements to the application. The application controls all elements that handle the exchange of data between the application and SQL statements, the management of cursor specifications that the user or application might construct, and the compilation and execution of SQL statements themselves.
Thus, dynamic ESQL request strings cannot contain the following:
- DECLARE CURSOR, OPEN, FETCH, or CLOSE statements used to manage cursor specifications.
Instead, ESQL provides dynamic forms of these statements. Your application can use these and other Progress/ESQL statements to perform all data and cursor specification management, as well as to compile and execute the SQL statements.
- References to embedded host variable names.
- SQL comments.
- Dynamic parameters in a context that prevents the data type of the surrounding expression from being inferred.
NOTE: Dynamic ESQL provides no way for the user or your application to directly specify a singleton SELECT (SELECT...INTO statement) that returns a single row of data. Instead, your application must execute SELECT statements as cursor specifications. These can also include SELECT statements that return a single row of data for retrieval using the dynamic FETCH statement. For more information, see the "Executing Dynamic Cursor Specifications" section in this chapter.To support run-time SQL statements, dynamic ESQL provides additional Progress/ESQL statements and ESQL-LIB functions. These functions support techniques that let you specify, compile, and execute SQL statements at run time. Much of this functionality allows the exchange of data between your application and the SQL statements. In static ESQL, this functionality is not needed because your application knows the content of all SQL statements at development time.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |