Logical Sequence of Database Operations 

The database operations are all related, and always occur in the same logical order:

The DECLARE function defines a cursor and assigns a number to it. DECLARE is followed by PREPARE.

PREPARE takes an SQL statement, for example:

select * from sflight where carrid eq 'LH' .

It determines the access method, and prepares the statement to be passed to the database. At this stage, the system is only concerned with the structure of the SQL statement, and not the values that it contains.

The OPEN function takes the prepared SQL statement and adds the relevant values to it. In the above example, OPEN would give the value LH for the field carrid.

FETCH passes the entries from the database to the database interface of the R/3 System. All of the database operations required to execute an SQL statement are linked by the same cursor ID.

If the SQL statement makes changes in the database (INSERT, UPDATE, DELETE), PREPARE is followed by EXEC, which executes the statement.

If the system can refer back to an SQL statement that has already been prepared, there is no PREPARE operation, and the statement is executed using REOPEN or REEXEC as appropriate.