Skip to main content

COBSQ0002 - sqlca is badly defined.

  • February 15, 2013
  • 0 replies
  • 0 views

Problem:

Release: 2.5   

Converting from COBOL Workbench\\XDB to Mainframe Express 2.5\\SQL option and receiving compiler error when sqlca defined only has pic x(136). This is not allowed in Mainframe Express.

COBSQ0002 indicates:

One of the following occurred.  Either the SQLCA area is defined with total length less than 136 characters, the SQLCODE field is not defined as a S9 (8) COMP field, the SQLSTATE field is not defined as a character field of length 5, or one of the previous fields is defined incorrectly.

Resolution:

Correct the definition or use the SQLCA copybook provided with Mainframe Express.  If problem persists, report this error to your support representative.  Trace files may be need to resolve this problem. See Creating Debug Files for details on how to create additional trace files that may be requested by your support representative.

In addition - According to the DB2 V6 manual -

3.4.3.1 Defining the SQL communication area

A COBOL program that contains SQL statements must include one or both of the following host variables:

# An SQLCODE variable declared as PIC S9(9) BINARY, PIC S9(9) COMP-4,

# PIC S9(9) COMP-5, or PICTURE S9(9) COMP

An SQLSTATE variable declared as PICTURE X(5)

Or,

An SQLCA, which contains the SQLCODE and SQLSTATE variables.

DB2 sets the SQLCODE and SQLSTATE values after each SQL statement executes. An application can check these variables value to determine whether the last SQL statement was successful. All SQL statements in the program must be within the scope of the declaration of the SQLCODE and SQLSTATE variables.

Whether you define SQLCODE or SQLSTATE, or an SQLCA, in your program depends on whether you specify the precompiler option STDSQL(YES) to conform to SQL standard, or STDSQL(NO) to conform to DB2 rules.

3.4.3.1.1 If you specify STDSQL(YES)

When you use the precompiler option STDSQL(YES), do not define an SQLCA. If you do, DB2 ignores your SQLCA, and your SQLCA definition causes compile-time errors.

When you use the precompiler option STDSQL(YES), you must declare an SQLCODE v

ariable. DB2 declares an SQLCA area for you in the WORKING-STORAGE SECTION. DB2 controls that SQLCA, so your application programs should not make assumptions about its structure or location.

If you declare an SQLSTATE variable, it must not be an element of a structure. You must declare the host variables SQLCODE and SQLSTATE within the statements BEGIN DECLARE SECTION and END DECLARE SECTION in your program declarations.

3.4.3.1.2 If you specify STDSQL(NO)

When you use the precompiler option STDSQL(NO), include an SQLCA explicitly. You can code the SQLCA in a COBOL program either directly or by using the SQL INCLUDE statement. The SQL INCLUDE statement requests a standard SQLCA declaration:

     EXEC SQL INCLUDE SQLCA END-EXEC.

You can specify INCLUDE SQLCA or a declaration for SQLCODE wherever you can specify a 77 level or a record description entry in the WORKING-STORAGE SECTION. You can declare a stand-alone SQLCODE variable in either the WORKING-STORAGE SECTION or LINKAGE SECTION.

Old KB# 6638

#MFDS
#EnterpriseDeveloper