Dismiss
InnovationQ will be updated on Sunday, Oct. 22, from 10am ET - noon. You may experience brief service interruptions during that time.
Browse Prior Art Database

Processing SQL Whenever Statements in Cobol

IP.com Disclosure Number: IPCOM000100615D
Original Publication Date: 1990-May-01
Included in the Prior Art Database: 2005-Mar-15
Document File: 3 page(s) / 79K

Publishing Venue

IBM

Related People

Hoffman, RD: AUTHOR

Abstract

Disclosed is a method for processing SQL WHENEVER statements imbedded in COBOL programs in a way which does not require restrictions or special compilation options.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 53% of the total text.

Processing SQL Whenever Statements in Cobol

       Disclosed is a method for processing SQL WHENEVER
statements imbedded in COBOL programs in a way which does not require
restrictions or special compilation options.

      The SQL WHENEVER statement is a precompiler directive that
tells the precompiler to generate error-trapping code after the code
for each executable SQL statement.  The pseudocode for the
error-trapping code looks something like this:
      IF (SQLCODE < 0) THEN
         GOTO the object of the WHENEVER SQLERROR statement.
      IF (SQLCODE = 100) THEN
         GOTO the object of the WHENEVER NOTFOUND statement.
      IF (SQLCODE > 0 OR SQLWARN0 = 'W') THEN
         GOTO the object of the WHENEVER SQLWARNING
         statement.

      In COBOL, a period is used to end the scope of an IF statement,
as shown in the example.  A problem arises if the SQL statement which
precedes the WHENEVER code is itself within the scope of an IF
statement. Then the periods which are required for the
error-processing statements may prematurely end the scope of the
outer IF statement and cause unexpected results.

      Several steps may be taken to avoid this.
      1. SQL source code can be restricted so that SQL statements
cannot occur with the scope of an IF statement. Most program
mers would find this restriction unacceptable.
2. Force the user to compile under ANS rules, which provide an
explicit ENDIF statement to delimit IF statement scope.  This reduces
the number of viable COBOL compilers a user might choose, restricts
the style of the program, and reduces the portability of older
programs.
3. Generate the WHENEVER processing code in PERFORM blocks, appended
to the end of the program.  This requires two passes (or the use of
side files), and causes poor precompiler and compiler performance.

      A new method solves this problem with none of the shortcomings
described above.

      At the end of each COBOL program, the following source is
generated:
      SQL-ERRCHECK.
          IF SQLCODE LESS THAN 0 THEN
             PERF...