The embedded SQLJ language

This chapter provides detailed information about using the Embedded SQLJ language. For syntax and reference information about specific statements, refer to the Informix® Guide to SQL: Syntax.

Embedded SQLJ has some differences from the earlier embedded SQL languages defined by ANSI/ISO: ESQL/C, ESQL/ADA, ESQL/FORTRAN, ESQL/COBOL, and ESQL/PL/1. The major differences are as follows:
  • The SQL connection statement of traditional embedded SQL is replaced by a Java™ connection-context object. This approach enables Embedded SQLJ programs to open multiple database connections simultaneously.
  • In Embedded SQLJ there is no host variable definition section (preceded by a BEGIN DECLARE SECTION statement and terminated by an END DECLARE SECTION statement). All legal Java variables can be used as host variables.
  • Embedded SQLJ does not include the WHENEVER...GOTO/ CONTINUE statement, because Java has well-developed rules for declaring and handling exceptions.
  • Embedded SQLJ uses iterator objects rather than cursors to manage result sets. A result-set iterator is a Java object from which you can retrieve the data returned by a SELECT statement. Unlike cursors, iterator objects can be passed as parameters to methods.
  • Embedded SQLJ supports access to data in columns of iterator objects by name, through generated accessor methods. You can also access this data by position using the FETCH...INTO statement, as used by traditional embedded SQL.
  • Unlike other host languages, Java allows null data. Therefore, you do not need to use null indicator variables with Embedded SQLJ.
  • Embedded SQLJ does not include dynamic SQL; you must use JDBC instead.

The files containing your Embedded SQLJ source code must have the extension .sqlj; for example, custapp.sqlj.