It is possible to attach a stream to a LOB locator, passing the LOB locator as a
:lob-locator
argument to
(make-instance 'sql:lob-stream ...)
. The value of the
:direction
argument must be
:input
or
:output
. By default, if the stream is closed the LOB locator is freed, unless the value of the initarg
:free-lob-locator-on-close
is passed as
nil
.
Operations via the stream can be mixed with direct operations on the LOB. However, because of the buffering, accessing the LOB contents will give non-obvious results, as other operations may not see something that was written to the stream because it is still in the stream buffer, or the stream may have already read some contents before they were overwritten. Use
force-output
or
clear-input
before accessing the LOB in other ways to avoid these problems.
It is possible to attach more than one stream to the same LOB locator, in both directions. Apart from the issue of the buffering described above, the streams can be used independently of each other. Note that if you want to close one of the streams and to continue to use the others or the LOB locator itself, you must pass
:free-lob-locator-on-close nil
when you make the stream.
The LOB locator to which a stream is attached can be found by using the reader
lob-stream-lob-locator
.