ALLBASE/SQL Reference Manual (36216-90216)

224 Chapter7
Data Types
Long Operations
Using INSERT with Heap Space Input and Output
You have the option of using a heap address to indicate the location of input data. Output
datamay be directed toa heap address generated by ALLBASE/SQL at output time. In the
next example, 4000 bytes of data flow from heap address 1230 to the PartsIllus table, and
when this data is selected or fetched, it goes to the heap address:
INSERT INTO PurchDB.PartsIllus
VALUES ('saw'
300,
'<%1230:4000 >%$')
Using SELECT with LONG Column Data
The concept of how data is retrieved differs from that of non-LONG columns. The output
portion of the LONG column I/O string (rather than the data itself) is obtained with the
SELECT or FETCH statement. The LONG data goes to a file or heap space.
In this example, the SELECT statement places the LONG data from the PartPicture column
in a file or in heap space, as specified in the LONG column I/O string when the PartPicture
column was inserted or updated. The SELECT statement puts the file name or heap space
address in the PartPicture LONG column descriptor. In an application, the contents of the
descriptor are placed in a host variable and may be parsed to extract the file name or heap
space address. When a long field column is selected using ISQL, the file name or heap
space address is displayed in the column whose heading is the long field name. Refer to the
"Programming with LONG Columns" chapter of the appropriate application programming
guide for information on the format of the LONG column descriptor.
SELECT PartPicture
FROM PurchDB.PartsIllus
WHERE PartName = 'saw'
Using UPDATE with LONG Column Data
When you issue an UPDATE on a LONG column, you have the following options:
Change the stored data as well as the output device name and/or options.
Change the stored data only.
Change the output device name and/or options only.
You must specify either the input device, the output device, or both.
Examples
The following examples present a sampling of possible combinations.
Using UPDATE to Change Stored Data and Output Device Name
In this example, data from the file newhammer.tools is inserted into the LONG column
PartPicture replacing the previously stored data. The output device name is changed to be
the file newhammer. Should file newhammer already exist when the SELECT or FETCH
statement is issued, it is not overwritten, and an error is generated.