Every ESL application that uses EDS must contain a minimum set of functionality. An application must connect to a data source, send SQL commands, receive return codes and possibly data, and terminate the connection. You can create such an application using only the Core commands. (Unless specifically noted, all subroutines and functions mentioned in this chapter are Core commands.) If you need additional functionality, the Level 1 and Level 2 commands provide more flexibility. (Refer to the Command Summary for descriptions of all the commands.)
To interact with a data source using EDS, your ESL application must perform the following actions:
1.Connect to the data source. Specify the data source name and any additional information needed to complete the connection.
2.Process one or more SQL statements:
3.Place the SQL text string into an ESL string variable. If the statement includes parameter markers, set the parameter values.
4.If the SQL statement will return a result set, your ESL application must assign a cursor name for the statement or allow the driver to do so.
5.Submit the SQL statement for prepared or immediate execution.
6.If the SQL statement will create a result set, your ESL application can inquire about the attributes of the result set, such as the number of columns and the name and type of a specific column. Assign an ESL variable for each column in the result set and fetch the results.
7.Retrieve the return code generated by the EDS command. If the SQL statement causes an error, retrieve error information from the driver and take appropriate action.
8.End each transaction by committing it or rolling it back.
9.Terminate the connection.
Figure 2-1 illustrates the sequence of EDS commands used to submit a SELECT statement and receive the result set. Optional commands appear in brackets.
Figure 2.1 EDS Commands for a SELECT Statement
Figure 2-2 below illustrates the sequence of EDS commands used to modify the database with an INSERT, UPDATE or DELETE command. (Optional commands are in brackets).
Figure 2-2: EDS Commands for an INSERT, UPDATE, or DELETE Statement