Rational Developer for System z
COBOL for Windows, Version 7.5, Programming Guide


Testing bits in ODBC calls

For some of the ODBC APIs, you must set bit masks and must query bits. You can use the library routine iwzODBCTestBits to query bits. You must link the IWZODBC.LIB import library with any application that calls iwzODBCTestBits.

Call this routine as follows:

CALL “iwzODBCTestBits” USING identifier-1, identifier-2 RETURNING identifier-3
identifier-1
The field being tested. It must be a 2- or 4-byte binary number field, that is, USAGE COMP-5 PIC 9(4) or PIC 9(9).
identifier-2
The bit mask field to select the bits to be tested. It must be defined with the same USAGE and PICTURE as identifier-1.
identifier-3
The return value for the test (define it as USAGE COMP-5 PICS9(4)):
0
No bits selected by identifier-2 are ON in identifier-1.
1
All bits selected by identifier-2 are ON in identifier-1.
-1
One or more bits are ON and one or more bits are OFF among the bits selected by identifier-2 for identifier-1.
-100
Invalid input-argument found (such as an 8-byte binary number field used as identifier-1).
 

You can set multiple bits in a field with COBOL arithmetic expressions that use the bit masks defined in the ODBCCOB copybook. For example, you can set bits for SQL-CVT-CHAR, SQL-CVT-NUMERIC, and SQL-CVT-DECIMAL in the InfoValue field with this statement:

COMPUTE InfoValue = SQL-CVT-CHAR + SQL-CVT-NUMERIC + SQL-CVT-DECIMAL

After you set InfoValue, you can pass it to the iwzTestBits function as the second argument.

The operands in the arithmetic expression above represent disjoint bits as defined in the ODBCCOB copybook. As a result, addition sets the intended bits on. Be careful to not repeat bits in such an arithmetic expression, however, because the operation is not logical OR. For example, the following code results in InfoValue not having the intended SQL-CVT-CHAR bit on:

COMPUTE InfoValue = SQL-CVT-CHAR + SQL-CVT-NUMERIC + SQL-CVT-DECIMAL + SQL-CVT-CHAR

The call interface convention in effect at the time of the call must be CALLINT SYSTEM DESCRIPTOR.


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)