You can enable the direct transfer of file content in and out of LONG columns by using the predefined data type SQLFILE to declare host variables.
Assign the name of a file to the value of the host variable. Note the following:
· If this file already exists, then its content must be a character string (of any length). The SQL statements INSERT and UPDATE write the content of the file to the LONG column.
· If this file does not already exist, the SELECT statements of a LONG column generate it with the specified file name. The column content becomes the content of the file.
· If this file already exists when a SELECT statement is executed, then the content of the LONG column is appended to its existing content. If you want to avoid this, you must delete the existing file before the SELECT statement is executed, for example, with an EXEC COMMAND statement.
· Any errors in the processing of the file terminate the SQL statement and trigger a database error message sqlcode < 0.
EXEC SQL BEGIN DECLARE SECTION;
SQLFILE f1[30] = "document.doc";
char title[41] = "Manual";
SQLFILE f2[30];
EXEC SQL END DECLARE SECTION;
EXEC SQL CREATE TABLE documents(title CHAR (40) KEY,
document LONG BYTE);
EXEC SQL INSERT INTO documents VALUES (:title, :f1);
strcpy (f2, "tempdocument.doc");
EXEC SQL SELECT document INTO :f2 FROM documents
WHERE title = :title;