7. Embedded SQL for Pascal : Advanced Processing : Sample Programs : Put Handler
 
Share this page                  
Put Handler
This user defined handler shows how an application can use the put data handler to enter a chapter of a book from a text file into a database.
function Put_Handler(info: hdlr_rec) : Integer;

begin
        process information passed in via the info record...
        open file ...

data_end := 0;

        while (not end-of-file) do begin

                read segment from file into seg_buf...

            if (end-of-file) then begin
                data_end := 1;
            end;

            exec sql put data (segment = :seg_buf,
                    segmentlength = :seg_len,
                     dataend = :data_end);

end; {while}
. . .
close file...
set info record to return appropriate values...
....
Put_Handler := 0 {return value ignored}

end {Put Handler }