sysVar.sqlwarn

The system array sysVar.sqlwarn is a static 11-element array, where each element contains a warning byte returned in the SQL communications area (SQLCA) for the last SQL I/O operation and where the index is one greater that the warning number in the SQL SQLCA description. The system variable sysVar.sqlwarn[2], for example, refers to SQLWARN1, which indicates whether characters in an item were truncated in the I/O operation.

Of the elements in sysVar.sqlwarn, only the system variable sysVar.sqlwarn[2] is refreshed by the database management system for Java code or at debugging time.

You can use sysVar.sqlwarn in these ways:

The characteristics of each element in the sysVar.sqlwarn array are as follows:

Primitive type

CHAR

Data length

1

Is value always restored after a converse?

Only in a non-segmented text program; for details see Segmentation

Definition considerations

sysVar.sqlwarn[2] contains W if the last SQL I/O operation caused the database manager to truncate character data items because of insufficient space in the program's host variables. You can use logical expressions to test whether the values in specific host variables were truncated. For details, see the references to trunc in Logical expressions.

When the host variable is a number, no truncation warning is given. Fractional parts of a number are truncated with no indication.

Example

In the following example, my-char-field is a field in the SQL row record just processed and lost-data is a function that sets an error message indicating that information for my-char-field was truncated.

  if (sysVar.sqlwarn[2] = 'W')
    if (my-char-field is trunc)
      lost-data();
    end
  end

Related concepts
Segmentation in text applications
SQL support

Related reference
File and database (system words)
Logical expressions