Data Handlers and the SQLDA
You may specify a user‑defined data handler as an SQLVAR element of the SQLDA, to transmit large objects to/from the database. The eqsqlda.h file included using the include sqlda statement declares one IISQLHDLR record which may be used to specify one data handler and its argument. It is defined:
* Declare IISQLHDLR
01 IISQLHDLR EXTERNAL.
05 SQLARG USAGE POINTER.
05 SQLHDLR PIC S9(9) USAGE COMP.
You can also code this record directly, instead of using the include sqlda statement. You can choose any name for the structure and you can declare more than one in a single program. The program must set the values:
* Declare the argument to be passed to datahandler
01 HDLR-ARG.
05 ARG-CHAR PIC X(100).
05 ARG-INT PIC S9(9) USAGE COMP.
* Declare the datahandler
01 GET-HANDLER PIC S9(9) USAGE COMP VALUE
EXTERNAL GET-HANDLER.
* Set the IISQLHDLR values for SQLHDLR and SQLARG
MOVE GET-HANDLER TO SQLHDLR.
SET SQLARG TO REFERENCE HDLR-ARG.
The sqltype and sqllen fields of the SQLVAR element of the SQLDA should then be set as follows:
MOVE 46 TO SQLTYPE(COL).
MOVE 0 TO SQLLEN(COL).