Language basics / Variables |
The LOCATE statement specifies where to store data of TEXT and BYTE variables.
LOCATE target [,...] IN MEMORY
LOCATE target [,...] IN FILE filename
LOCATE target [,...] IN FILE
Defining the location of TEXT and BYTE large object data is mandatory before usage and must be done with the LOCATE instruction.
After defining the data storage, the variable can be used as input parameter or as a fetch buffer in SQL statements, as well as in interaction statements and reports.
You cannot use a large object variable if the data storage location is not defined.
The first syntax using the IN MEMORY clause specifies that the large object data must be located in memory. The second syntax using the IN FILE filename clause specifies that the large object data must be located in a specific file. The third syntax using the IN FILE clause specifies that the large object data must be located in a temporary file.
When using a temporary file, the location of the temporary file can be defined with the DBTEMP environment variable. By default, the runtime system will use /tmp on UNIX™ and %TMP% or %TEMP% on Windows™. The temporary files are automatically dropped by the runtime system when the program terminates. On UNIX systems, the permission on the temporary file can be controlled by umask.
The FREE instruction can be used to free the resources allocated to the large object variable.
MAIN DEFINE ctext1, ctext2 TEXT DATABASE stock LOCATE ctext1 IN MEMORY LOCATE ctext2 IN FILE "/tmp/data1.txt" CREATE TABLE lobtab ( key INTEGER, col1 TEXT, col2 TEXT ) INSERT INTO lobtab VALUES ( 123, ctext1, ctext2 ) END MAIN