5. Embedded SQL for Ada : Advanced Processing : User-Defined Data Handlers for Large Objects : DATAHANDLERS and the SQLDA
 
Share this page                  
DATAHANDLERS and the SQLDA
You may specify a user-defined datahandler as an SQLVAR element of the SQLDA, to transmit large objects to or from the database. The eqsqlda.h file included with the include sqlda statement defines an IISQLDHDLR type which may be used to specify a datahandler and its argument. It is defined:
--
-- IISQLHDLR - Structure type with function pointer and
--             function argument for the DATAHANDLER.
--
type IISQLHDLR is
    record
       sqlarg:  Address;-- Optional argument to pass
       sqlhdlr: Address;--User-defined datahandler function
    end record;
The file does not declare an IISQLHDLR variable; the program must declare a variable of the specified type and set the values:
-- Declare argument to be passed to datahandler
      hdlr_arg:     Hdlr_Rec;

-- Declare IISQLHDLR
      data_handler: IISQLHDLR;
-- Declare Get_Handler function to return an integer
function Get_Handler(info: Hdlr_Rec) return Integer
        data_handler.sqlhdlr = Get_Handler'Address;
        data_handler.sqlarg     = hdlr_arg'Address;
The sqltype, sqlind and sqldata fields of the SQLVAR element of the SQLDA should then be set as follows:
    sqlda.sqlvar(i).sqltype := IISQ_HDLR_TYPE;
    sqlda.sqlvar(i).sqldata := data_handler'Address;
    sqlda.sqlvar(i).sqlind  := indvar'Address'