6. Embedded SQL for BASIC : Advanced Processing : Sample Programs : Get Handler
 
Share this page                  
Get Handler
This user-defined data handler shows how an application can use the get data handler to enter a chapter of a book from a text file into a database.
! Get_Handler
!    *************
200 integer function Get_Handler(hdlr_arg info)
        record hdlr_arg
            string     argstr
            integer    argint
        end record hdlr_arg
        exec sql begin declare section
            declare string         segbuf
            declare integer seglen
            declare integer datend
            declare integer     maxlen
        exec sql end declare section
            
        ...
        process information passed in via the
             info record...
        open file....

        datend = 0
        
        while (datend = 0)
            exec sql get data (:segbuf = segment,&
             :seglen = segmentlenght, & :datend = dataend) &
            with maxlength = :maxlen
        write segment to file

        next
        ...
        set info record to return appropriate values...
        ...

        Get_Handler = 0

end function