User-Defined Data Handlers for Large Objects
You can use user-defined data handlers to transmit large object column values to or from the database a segment at a time. For more details on large objects, the data handler clause, the get data statement and the put data statement, see the SQL Reference Guide and the Forms‑based Application Development Tools User Guide.
ESQL/C Usage Notes
When using ESQL/C, the following notes apply:
• The data handler, and the data handler argument, should not be declared in an ESQL declare section. Therefore do not use a colon before the data handler or its argument.
• You must ensure that the data handler argument is a valid C pointer. ESQL will not do any syntax or datatype checking of the argument.
• The data handler must be declared to return an integer. However, the actual return value will be ignored.
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 via the include sqlda statement defines an IISQLHDLR type that may be used to specify a data handler and its argument. It is defined:
typedef struct sq_datahdlr
{
char *sqlarg; /* optional argument to pass */
int (*sqlhdlr)(); /* user-defined datahandler */
} IISQLHDLR;
The file does not declare an IISQLHDLR variable; the program must declare a variable of the specified type and set the values:
IISQLHDLR data_handler;
char *arg;
int Get_Handler();
data_handler.sqlarg = arg;
data_handler.sqlhdlr = Get_Handler;
The sqltype, sqllen and sqldata fields of the SQLVAR element of the SQLDA should then be set as follows:
/*
** assume sqlda is a pointer to a dynamically allocated ** SQLDA
*/
sqlda->sqlvar[i].sqltype = IISQ_HDLR_TYPE;
sqlda->sqlvar[i].sqllen = 0;
sqlda->sqlvar[i].sqldata = (char*)&data_handler;
To indicate nullability for a column set sqltype to negative IISQ_HDLR_TYPE, as shown in the following code fragment:
sqlda->sqlvar[i].sqltype = -IISQ_HDLR_TYPE;
Last modified date: 04/03/2024