fromfile, fromfiletext

The fromfile and fromfiletext functions read a file. The syntax is

   fromfile(filename[, offset[, length]])
   fromfiletext(filename[, offset[, length]])

These functions take one required, and two optional arguments. The first argument is the filename. The second argument is an offset into the file, and the third argument is the length of data to read. If the second argument is omitted then the file will be read from the beginning. If the third argument is omitted then the file will be read to the end. The result is the contents of the file. This can be used to load data into a table. For example if you have an indirect field and you wish to see the contents of the file you can issue SQL similar to the following.

The difference between the two functions is the type of data that is returned. fromfile will return varbyte data, and fromfiletext will return varchar data. If you are using the functions to insert data into a field you should make sure that you use the appropriate function for the type of field you are inserting into.

     SELECT  FILENAME, fromfiletext(FILENAME)
     FROM    DOCUMENTS
     WHERE   DOCID = 'JT09113' ;

The results are:

  FILENAME            fromfiletext(FILENAME)
  /docs/JT09113.txt   This is the text contained in the document
  that has an id of JT09113.

Copyright © Thunderstone Software     Last updated: Sep 12 2017
Copyright © 2017 Thunderstone Software LLC. All rights reserved.