Oracle® Call Interface Programmer's Guide 11g Release 2 (11.2) Part Number E10646-10 |
|
|
PDF · Mobi · ePub |
Table E-4 lists the deprecated LOB functions that are described in this section.
Table E-4 Deprecated LOB Functions
Function | Purpose |
---|---|
Copy all or part of one LOB to another. |
|
Erase a portion of a LOB. |
|
Get length of a LOB. |
|
Load a LOB from a |
|
Read a portion of a LOB. |
|
Truncate a LOB. |
|
Write into a LOB. |
|
Write data beginning at the end of a LOB. |
Copies all or a portion of a LOB value into another LOB value. This function is deprecated. Use OCILobCopy2().
sword OCILobCopy ( OCISvcCtx *svchp, OCIError *errhp, OCILobLocator *dst_locp, OCILobLocator *src_locp, ub4 amount, ub4 dst_offset, ub4 src_offset );
See:
"OCILobCopy2()"Erases a specified portion of the internal LOB data starting at a specified offset. This function is deprecated. Use OCILobErase2().
sword OCILobErase ( OCISvcCtx *svchp, OCIError *errhp, OCILobLocator *locp, ub4 *amount, ub4 offset );
See:
"OCILobErase2()"Gets the length of a LOB. This function is deprecated. Use OCILobGetLength2().
sword OCILobGetLength ( OCISvcCtx *svchp, OCIError *errhp, OCILobLocator *locp, ub4 *lenp );
See:
"OCILobGetLength2()"Loads and copies all or a portion of the file into an internal LOB. This function is deprecated. Use OCILobLoadFromFile2().
sword OCILobLoadFromFile ( OCISvcCtx *svchp, OCIError *errhp, OCILobLocator *dst_locp, OCILobLocator *src_locp, ub4 amount, ub4 dst_offset, ub4 src_offset );
Reads a portion of a LOB or BFILE
, as specified by the call, into a buffer. This function is deprecated. Use OCILobRead2().
sword OCILobRead ( OCISvcCtx *svchp, OCIError *errhp, OCILobLocator *locp, ub4 *amtp, ub4 offset, void *bufp, ub4 bufl, void *ctxp, OCICallbackLobRead (cbfp) ( void *ctxp, const void *bufp, ub4 len, ub1 piece ) ub2 csid, ub1 csfrm );
The service context handle.
An error handle that you can pass to OCIErrorGet() for diagnostic information when there is an error.
A LOB or BFILE
locator that uniquely references the LOB or BFILE
. This locator must have been a locator that was obtained from the server specified by svchp
.
The value in amtp
is the amount in either bytes or characters, as shown in Table E-5.
Table E-5 Characters or Bytes in amtp for OCILobRead()
LOB or BFILE | Input | Output with Fixed-Width Client-Side Character Set | Output with Varying-Width Client-Side Character Set |
---|---|---|---|
|
bytes |
bytes |
bytes |
|
characters |
characters |
bytes Foot 1 |
Footnote 1 The input amount refers to the number of characters to be read from the server-side CLOB
or NCLOB
. The output amount indicates how many bytes were read into the buffer bufp
.
The parameter amtp
is the total amount of data read if:
Data is not read in streamed mode (only one piece is read and there is no polling or callback)
Data is read in streamed mode with a callback
The parameter amtp
is the length of the last piece read if the data is read in streamed mode using polling.
If the amount to be read is larger than the buffer length, it is assumed that the LOB is being read in a streamed mode from the input offset until the end of the LOB, or until the specified number of bytes have been read, whichever comes first. On input, if this value is 0, then the data is read in streamed mode from the input offset until the end of the LOB.
The streamed mode (implemented with either polling or callbacks) reads the LOB value sequentially from the input offset.
If the data is read in pieces, the amtp
parameter always contains the length of the piece just read.
If a callback function is defined, then this callback function is invoked each time bufl
bytes are read off the pipe. Each piece is written into bufp
.
If the callback function is not defined, then the OCI_NEED_DATA
error code is returned. The application must call OCILobRead()
over and over again to read more pieces of the LOB until the OCI_NEED_DATA
error code is not returned. The buffer pointer and the length can be different in each call if the pieces are being read into different sizes and locations.
On input, this is the absolute offset from the beginning of the LOB value. For character LOBs (CLOB
s, NCLOB
s) it is the number of characters from the beginning of the LOB, for binary LOBs or BFILE
s it is the number of bytes. The first position is 1.
If you use streaming (by polling or a callback), specify the offset in the first call; in subsequent polling calls, the offset parameter is ignored. When you use a callback, there is no offset parameter.
The pointer to a buffer into which the piece is read. The length of the allocated memory is assumed to be bufl
.
The length of the buffer in octets. This value differs from the amtp
value for CLOB
s and for NCLOB
s (csfrm
=SQLCS_NCHAR
) when the amtp
parameter is specified in terms of characters, and the bufl
parameter is specified in terms of bytes.
The context pointer for the callback function. Can be NULL
.
A callback that can be registered to be called for each piece. If this is NULL
, then OCI_NEED_DATA
is returned for each piece.
The callback function must return OCI_CONTINUE
for the read to continue. If any other error code is returned, the LOB read is terminated.
The context for the callback function. Can be NULL
.
A buffer pointer for the piece.
The length in bytes of the current piece in bufp
.
Which piece: OCI_FIRST_PIECE
, OCI_NEXT_PIECE
, or OCI_LAST_PIECE
.
The character set ID of the buffer data. If this value is 0, then csid
is set to the client's NLS_LANG
or NLS_CHAR
value, depending on the value of csfrm
. It is never assumed to be the server's character set, unless the server and client have the same settings.
The character set form of the buffer data. The csfrm
parameter must be consistent with the type of the LOB.
The csfrm
parameter has two possible nonzero values:
The default value is SQLCS_IMPLICIT
. If csfrm
is not specified, the default is assumed.
Reads a portion of a LOB or BFILE
as specified by the call into a buffer. It is an error to try to read from a NULL
LOB or BFILE
.
Note:
When you you read or write LOBs, specify a character set form (csfrm
) that matches the form of the locator itself.For BFILE
s, the operating system file must exist on the server, and it must have been opened by OCILobFileOpen() or OCILobOpen() using the input locator. Oracle Database must have permission to read the operating system file, and the user must have read permission on the directory object.
When you use the polling mode for OCILobRead()
, the first call must specify values for offset
and amtp
, but on subsequent polling calls to OCILobRead()
, you need not specify these values.
If the LOB is a BLOB
, the csid
and csfrm
parameters are ignored.
Note:
To terminate anOCILobRead()
operation and free the statement handle, use the OCIBreak() call.The following apply to client-side varying-width character sets for CLOB
s and NCLOB
s:
When you use polling mode, be sure to specify the amtp
and offset
parameters only in the first call to OCILobRead()
. On subsequent polling calls, these parameters are ignored.
When you use callbacks, the len
parameter, which is input to the callback, indicates how many bytes are filled in the buffer. Check the len
parameter during your callback processing because the entire buffer cannot be filled with data.
The following applies to client-side fixed-width character sets and server-side varying-width character sets for CLOB
s and NCLOB
s:
When reading a CLOB
or NCLOB
value, look at the amtp
parameter after every call to OCILobRead()
to see how much of the buffer is filled. When the return value is in characters (as when the client-side character set is fixed-width), then convert this value to bytes and determine how much of the buffer is filled. When you use callbacks, always check the len
parameter to see how much of the buffer is filled. This value is always in bytes.
To read data in UTF-16 format, set the csid
parameter to OCI_UTF16ID
. If the csid
parameter is set, it overrides the NLS_LANG
environment variable.
See Also:
"PL/SQL REF CURSORs and Nested Tables in OCI" for additional information about Unicode format
Oracle Database SecureFiles and Large Objects Developer's Guide for a description of BFILE
s
The demonstration programs included with your Oracle Database installation for a code sample showing the use of LOB reads and writes.
"Runtime Data Allocation and Piecewise Operations in OCI" for general information about piecewise OCI operations
OCIErrorGet(),OCILobRead2(), OCILobWrite(), OCILobWrite2(), OCILobFileSetName(), OCILobWriteAppend(), OCILobWriteAppend2()
Truncates the LOB value to a shorter length. This function is deprecated. Use OCILobTrim2().
sword OCILobTrim ( OCISvcCtx *svchp, OCIError *errhp, OCILobLocator *locp, ub4 newlen );
See:
"OCILobTrim2()"Writes a buffer into a LOB. This function is deprecated. Use OCILobWrite2().
sword OCILobWrite ( OCISvcCtx *svchp, OCIError *errhp, OCILobLocator *locp, ub4 *amtp, ub4 offset, void *bufp, ub4 buflen, ub1 piece, void *ctxp, OCICallbackLobWrite (cbfp) ( void *ctxp, void *bufp, ub4 *lenp, ub1 *piecep ) ub2 csid, ub1 csfrm );
The service context handle.
An error handle that you can pass to OCIErrorGet() for diagnostic information when there is an error.
An internal LOB locator that uniquely references the LOB. This locator must have been a locator that was obtained from the server specified by svchp
.
The value in amtp
is the amount in either bytes or characters, as shown in Table E-6.
Table E-6 Characters or Bytes in amtp for OCILobWrite()
LOB or BFILE | Input with Fixed-Width Client-Side Character Set | Input with Varying-Width Client-Side Character Set | Output |
---|---|---|---|
|
bytes |
bytes |
bytes |
|
characters |
bytes Foot 1 |
characters |
Footnote 1 The input amount refers to the number of bytes of data that the user wants to write into the LOB and not the number of bytes in the bufp
, which is specified by buflen
. If data is written in pieces, the amount of bytes to write may be larger than the buflen
. The output amount refers to the number of characters written into the server-side CLOB
or NCLOB
.
This should always be a non-NULL
pointer. If you want to specify write-until-end-of-file, then you must declare a variable, set it equal to zero, and pass its address for this parameter.
If the amount is specified on input, and the data is written in pieces, the parameter amtp
contains the total length of the pieces written at the end of the call (last piece written) and is undefined in between. Note that it is different from the piecewise read case. An error is returned if that amount is not sent to the server.
If amtp
is zero, then streaming mode is assumed, and data is written until the user specifies OCI_LAST_PIECE
.
On input, it is the absolute offset from the beginning of the LOB value. For character LOBs, it is the number of characters from the beginning of the LOB; for binary LOBs, it is the number of bytes. The first position is 1.
If you use streaming (by polling or a callback), specify the offset in the first call; in subsequent polling calls, the offset parameter is ignored. When you use a callback, there is no offset parameter.
The pointer to a buffer from which the piece is written. The length of the data in the buffer is assumed to be the value passed in buflen
. Even if the data is being written in pieces using the polling method, bufp
must contain the first piece of the LOB when this call is invoked. If a callback is provided, bufp
must not be used to provide data or an error results.
The length, in bytes, of the data in the buffer. This value differs from the amtp
value for CLOB
s and NCLOB
s when the amtp
parameter is specified in terms of characters, and the buflen
parameter is specified in terms of bytes.
Note:
This parameter assumes an 8-bit byte. If your operating system uses a longer byte, you must adjust the value ofbuflen
accordingly.Which piece of the buffer is being written. The default value for this parameter is OCI_ONE_PIECE
, indicating that the buffer is written in a single piece. The following other values are also possible for piecewise or callback mode: OCI_FIRST_PIECE
, OCI_NEXT_PIECE
, and OCI_LAST_PIECE
.
The context for the callback function. Can be NULL
.
A callback that can be registered to be called for each piece in a piecewise write. If this is NULL
, the standard polling method is used.
The callback function must return OCI_CONTINUE
for the write to continue. If any other error code is returned, the LOB write is terminated. The callback takes the following parameters:
The context for the callback function. Can be NULL
.
A buffer pointer for the piece. This is the same as the bufp
passed as an input to the OCILobWrite()
routine.
The length (in bytes) of the data in the buffer (IN), and the length (in bytes) of the current piece in bufp
(OUT).
Which piece: OCI_NEXT_PIECE
or OCI_LAST_PIECE
.
The character set ID of the data in the buffer. If this value is 0, then csid
is set to the client's NLS_LANG
or NLS_CHAR
value, depending on the value of csfrm
.
The character set form of the buffer data. The csfrm
parameter must be consistent with the type of the LOB.
The csfrm
parameter has two possible nonzero values:
The default value is SQLCS_IMPLICIT
.
Writes a buffer into an internal LOB as specified. If LOB data exists, it is overwritten with the data stored in the buffer. The buffer can be written to the LOB in a single piece with this call, or it can be provided piecewise using callbacks or a standard polling method.
Note:
When you read or write LOBs, specify a character set form (csfrm
) that matches the form of the locator itself.When you use the polling mode for OCILobWrite()
, the first call must specify values for offset
and amtp
, but on subsequent polling calls to OCILobWrite()
, you need not specify these values.
If the value of the piece
parameter is OCI_FIRST_PIECE
, data may need to be provided through callbacks or polling.
If a callback function is defined in the cbfp
parameter, then this callback function is invoked to get the next piece after a piece is written to the pipe. Each piece is written from bufp
. If no callback function is defined, then OCILobWrite()
returns the OCI_NEED_DATA
error code. The application must call OCILobWrite()
again to write more pieces of the LOB. In this mode, the buffer pointer and the length can be different in each call if the pieces are of different sizes and from different locations.
A piece
value of OCI_LAST_PIECE
terminates the piecewise write, regardless of whether the polling or callback method is used.
If the amount of data passed to Oracle Database (through either input mechanism) is less than the amount specified by the amtp
parameter, an ORA-22993 error is returned.
This function is valid for internal LOBs only. BFILE
s are not allowed, because they are read-only. If the LOB is a BLOB
, the csid
and csfrm
parameters are ignored.
If the client-side character set is varying-width, then the input amount is in bytes and the output amount is in characters for CLOB
s and NCLOB
s. The input amount refers to the number of bytes of data that the user wants to write into the LOB and not the number of bytes in the bufp
, which is specified by buflen
. If data is written in pieces, the amount of bytes to write may be larger than the buflen
. The output amount refers to the number of characters written into the server-side CLOB
or NCLOB
.
To write data in UTF-16 format, set the csid
parameter to OCI_UTF16ID
. If the csid
parameter is set, it overrides the NLS_LANG
environment variable.
It is not mandatory that you wrap this LOB operation inside the open or close calls. If you did not open the LOB before performing this operation, then the functional and domain indexes on the LOB column are updated during this call. However, if you did open the LOB before performing this operation, then you must close it before you commit or roll back your transaction. When an internal LOB is closed, it updates the functional and domain indexes on the LOB column.
If you do not wrap your LOB operations inside the open or close API, then the functional and domain indexes are updated each time you write to the LOB. This can adversely affect performance. If you have functional or domain indexes, Oracle recommends that you enclose write operations to the LOB within the open or close statements.
See Also:
"PL/SQL REF CURSORs and Nested Tables in OCI" for additional information about Unicode format
The demonstration programs included with your Oracle Database installation for a code sample showing the use of LOB reads and writes.
"Runtime Data Allocation and Piecewise Operations in OCI" for general information about piecewise OCI operations
OCIErrorGet(), OCILobRead(), OCILobRead2(), OCILobAppend(), OCILobCopy(), OCILobCopy2(), OCILobWriteAppend(), OCILobWriteAppend2(), OCILobWrite2()
Writes data starting at the end of a LOB. This function is deprecated. Use OCILobWriteAppend2().
sword OCILobWriteAppend ( OCISvcCtx *svchp, OCIError *errhp, OCILobLocator *locp, ub4 *amtp, void *bufp, ub4 buflen, ub1 piece, void *ctxp, OCICallbackLobWrite (cbfp) ( void *ctxp, void *bufp, ub4 *lenp, ub1 *piecep ) ub2 csid, ub1 csfrm );
The service context handle.
An error handle that you can pass to OCIErrorGet() for diagnostic information when there is an error.
An internal LOB locator that uniquely references a LOB.
The value in amtp
is the amount in either bytes or characters, as shown in Table E-7.
Table E-7 Characters or Bytes in amtp for OCILobWriteAppend()
LOB or BFILE | Input with Fixed-Width Client-Side Character Set | Input with Varying-Width Client-Side Character Set | Output |
---|---|---|---|
|
bytes |
bytes |
bytes |
|
characters |
bytes Foot 1 |
characters |
Footnote 1 The input amount refers to the number of bytes of data that the user wants to write into the LOB and not the number of bytes in the bufp,
which is specified by buflen
. If data is written in pieces, the amount of bytes to write may be larger than the buflen
. The output amount refers to the number of characters written into the server-side CLOB
or NCLOB
.
If the amount is specified on input, and the data is written in pieces, the parameter amtp
contains the total length of the pieces written at the end of the call (last piece written) and is undefined in between. (Note it is different from the piecewise read case). An error is returned if that amount is not sent to the server. If amtp
is zero, then streaming mode is assumed, and data is written until the user specifies OCI_LAST_PIECE
.
If the client-side character set is varying-width, then the input amount is in bytes, not characters, for CLOB
s or NCLOB
s.
The pointer to a buffer from which the piece is written. The length of the data in the buffer is assumed to be the value passed in buflen
. Even if the data is being written in pieces, bufp
must contain the first piece of the LOB when this call is invoked. If a callback is provided, bufp must not be used to provide data or an error results.
The length, in bytes, of the data in the buffer. Note that this parameter assumes an 8-bit byte. If your operating system uses a longer byte, the value of buflen
must be adjusted accordingly.
Which piece of the buffer is being written. The default value for this parameter is OCI_ONE_PIECE
, indicating that the buffer is written in a single piece. The following other values are also possible for piecewise or callback mode: OCI_FIRST_PIECE
, OCI_NEXT_PIECE
, and OCI_LAST_PIECE
.
The context for the callback function. Can be NULL
.
A callback that can be registered to be called for each piece in a piecewise write. If this is NULL
, the standard polling method is used. The callback function must return OCI_CONTINUE
for the write to continue. If any other error code is returned, the LOB write is terminated. The callback takes the following parameters:
The context for the callback function. Can be NULL
.
A buffer pointer for the piece.
The length (in bytes) of the data in the buffer (IN), and the length (in bytes) of the current piece in bufp
(OUT).
Which piece: OCI_NEXT_PIECE
or OCI_LAST_PIECE
.
The character set ID of the buffer data.
The character set form of the buffer data.
The csfrm
parameter has two possible nonzero values:
The default value is SQLCS_IMPLICIT
.
The buffer can be written to the LOB in a single piece with this call, or it can be provided piecewise using callbacks or a standard polling method. If the value of the piece parameter is OCI_FIRST_PIECE
, data must be provided through callbacks or polling. If a callback function is defined in the cbfp
parameter, then this callback function is invoked to get the next piece after a piece is written to the pipe. Each piece is written from bufp
. If no callback function is defined, then OCILobWriteAppend()
returns the OCI_NEED_DATA
error code.
The application must call OCILobWriteAppend()
again to write more pieces of the LOB. In this mode, the buffer pointer and the length can be different in each call if the pieces are of different sizes and from different locations. A piece value of OCI_LAST_PIECE
terminates the piecewise write.
OCILobWriteAppend()
is not supported if LOB buffering is enabled.
If the LOB is a BLOB
, the csid
and csfrm
parameters are ignored.
If the client-side character set is varying-width, then the input amount is in bytes, not characters, for CLOB
s or NCLOB
s.
It is not mandatory that you wrap this LOB operation inside the open or close calls. If you did not open the LOB before performing this operation, then the functional and domain indexes on the LOB column are updated during this call. However, if you did open the LOB before performing this operation, then you must close it before you commit or roll back your transaction. When an internal LOB is closed, it updates the functional and domain indexes on the LOB column.
If you do not wrap your LOB operations inside the open or close API, then the functional and domain indexes are updated each time you write to the LOB. This can adversely affect performance. If you have functional or domain indexes, Oracle recommends that you enclose write operations to the LOB within the open or close statements.
See Also:
"Improving LOB Read/Write Performance"OCIErrorGet(), OCILobRead(), OCILobRead2(), OCILobAppend(), OCILobCopy(), OCILobCopy2(), OCILobWrite(), OCILobWrite2(), OCILobWriteAppend2()