DB2Factory.com 

Java Script / COBOL CGI / COBOL SQL

API Declarations.


The communication between the COBOL/CGI program and the COBOL/SQL program uses the data structure in the COBOL copybook "XNCAB6.CPY". The CGI program uses the following copy statement to include the data structure:

01 dfhcommarea pic x(32768) value spaces.

1 ws-commarea redefines dfhcommarea.
 5 ws-action-block.
   7 ws-sql-action      pic x.
   7 ws-exec-this-pgm   pic x(8).
   7 ws-row-len         pic -9(5).
   7 ws-req-row-count   pic -9(5).
   7 ws-buf-count       pic -9(5).
   7 ws-cics-ret        pic -9(5).
   7 ws-db2-ret         pic -9(5).
   7 ws-que-count       pic -9(5).
   7 ws-que-name        pic x(8).
   7 ws-ip-address      pic x(15).
 5 ws-db2-data-area     pic x(29000).
 5 ws-db2-data REDEFINES
   ws-db2-data-area     pic x(29000).

The following is a detailed explanation of each field in the communication buffer:

dfhcommarea - Place holder for the 32k comm buffer storage allocation.

sql-action - valid values are 'F' 'S' 'U' 'I' 'D' - Specified by the calling program, these values stand for Fetch, Select, Insert, Update, and Delete. The value you move to this field will determine the action taken by the COBOL/SQL program. A return code of 9998 in field db2-ret indicates an invalid sql-action was detected. This field is case sensitive.

exec-this-program - This eight byte field contains the name of COBOL/SQL program to be called. This value is supplied by the calling program.

row-len -  This value is returned to the calling program from the COBOL/SQL program. It is the length of one row in the result set.

req-row-count - Requested row count. This field contains a display integer value from  1 to 99999. In the case of a FETCH action, this will be the number of rows to fetch. In the case of Insert, Update, or Delete - this field contains the number pf rows in the buffer to process.

buf-count - This field is populated by the COBOL/SQL program and passed back to the calling application. It contains the number of rows processed. In the case of a Fetch, this is the number of rows returned in the db2-data-area. In the case of an Insert, Update, or Delete - this is the number of rows processed.

cics-ret - This field is populated by the COBOL/SQL program and passed back to the calling application. It contains the CICS return code, if any, from the CICS environment.

db2-ret - This field is passed back to the calling program and contains the DB2 return code.

que-count - When a result set spans more than 30k, the first buffer is passed directly back to the calling program. The balance of the 30k buffers are written to a queue file named in the attribute 'que-name'. These buffers must be programmatically read from the queue file until eof. See the demo source code for an example of how to do this.

que-name - This eight byte field contains the name of the file that contains the balance of the buffer data beyone the first 30k. In a non-cics environment, this field defaults to "programname.que'. In a CICS environment, this is a unique temp storage queue id.

ip-address - This field contains the 15 bytes that will be put into the created and revised timestamps on an Insert, or Update. Although it is recommended that you use an IP address, any value will work as long as it makes sense to you and your application.