READTEXT Statement

Reads text and image values, starting from a specified offset and reading a specified number of bytes.

Syntax

READTEXT [[database.]owner.]table_name.column_name
text_ptr offset size [HOLDLOCK]

where

[database.]owner.]table_name.column_name
Specifies a table and column. Both names must be included, but the database name and owner name are optional.
text_ptr
Is a valid text pointer.
offset
Specifies the number of bytes to skip before starting to read the text or image data.
size
Specifies the number of bytes of data to read. If size is 0, 4K bytes of data are read.
HOLDLOCK
Causes the text value to be locked for reads until the end of the transaction. Other users can read the value, but they cannot modify it.

Remarks

READTEXT is used with a text_ptr. The value of text_ptr can be obtained using the TEXTPTR function. The TEXTPTR function returns a pointer to the text or image column in the specified row or to the text or image column in the last row returned by the query if more than one row is returned. Since the TEXTPTR function returns a 16-byte binary string, it is best to declare a local variable to hold the text pointer and then use the variable with READTEXT.

The value in the global variable @@TEXTSIZE, which is the limit on the number of bytes of data to be returned, supersedes the size specified for READTEXT if it is less than the specified size for READTEXT. For details on how to set the session setting for TEXTSIZE, see the SET statement.

Permission

Users must have SELECT permission on the table to use READTEXT. READTEXT permission is transferred when SELECT permission is transferred.