Get Handler
This example shows how to get the long varchar chapter_text from the database and write it to a text file:
C Get_Handler
C ***********
integer function Get_Handler(info)
structure /hdlr_arg/
character*100 argstr
integer argint
end structure
record /hdlr_arg/ info
exec sql begin declare section
character*2000 segbuf
integer*4 seglen
integer*4 datend
integer*4 maxlen
exec sql end declare section
process information passed in via the info record ...
open file ...
C Get a maximum segment length of 2000 bytes
maxlen = 2000
datend = 0
do while (datend .eq. 0)
C segmentlength: will contain the length of the segment retrieved.
C seg_buf: will contain a segment of the column chapter_text
C data_end: will be set to '1' when the entire value in
C chapter_text has been retrieved.
exec sql get data (:seqbuf = segment, :seglen =
1 segmentlength, :datend = dataend)
2 with maxlength= :maxlen
write segment to file ...
end do
...
set info record to return appropriate values ...
...
Get_Handler = 0
end