The lld_copy_subset routine

The following example shows how to use the lld_copy_subset user-defined routine defined in the previous section.
Figure 1: The lld_copy_subset routine
-- Using the lld_copy_subset function

create function lld_copy_subset (lld_locator, lld_locator, int8, int)
    returns lld_locator
    external name '/tmp/sapidemo.so'
    language c;

insert into lobs
    values (5, lld_copy_subset (
        "row('ifx_file',null,'/tmp/quote3.txt')"::lld_locator,
    "row('ifx_clob',null,null)"::lld_locator, 20, 70));

select lo from lobs where key = 5;
select lo.lo_pointer::clob from lobs where key = 5;

The lld_copy_subset function copies 70 bytes, beginning at offset 20 from the quote3.txt file, and appends them to a CLOB object. The INSERT statement inserts this data into the lobs table.

The first SELECT statement returns the lld_locator that identifies the newly copied CLOB data. The second SELECT statement returns the data itself.