How to disconnect from embedded SQL applications

The disconnect statement is the final step you must take when you are working with a database.

Disconnecting from Db2® databases in C and C++ Embedded SQL applications

When working with C and C++ applications, a database connection is closed by issuing the following statement:

    EXEC SQL CONNECT RESET;
  

Applications that are precompiled with the COMPATIBILITY_MODE ORA option can issue one of the following statements to achieve the ROLLBACK operation along with the disconnect operation in a single statement:

  • EXEC SQL ROLLBACK RELEASE;
  • EXEC SQL ROLLBACK WORK RELEASE;

Applications that are precompiled with the COMPATIBILITY_MODE ORA option can issue one of the following statements to achieve the COMMIT operation along with the disconnect operation in a single statement:

  • EXEC SQL COMMIT RELEASE;
  • EXEC SQL COMMIT WORK RELEASE;

Disconnecting from Db2 databases in COBOL Embedded SQL applications

When working with COBOL applications, a database connection is closed by issuing the following statement:

    EXEC SQL CONNECT RESET END-EXEC.
  

Disconnecting from Db2 databases in REXX Embedded SQL applications

When working with REXX applications, a database connection is closed by issuing the following statement:

    CALL SQLEXEC 'CONNECT RESET'
  

When working with FORTRAN applications, a database connection is closed by issuing the following statement:

    EXEC SQL CONNECT RESET