TextPointer Object

The text and image columns contain timestamp and page-location information that is separate from their text and image data.

When data is selected from a text or image column, this extra information is “hidden” as part of the result set.

A TextPointer object for updating an image column requires this hidden information but does not need the image portion of the column data. To get this information, select the column into a ResultSet object, then use SybResultSet.getTextPtr, which extracts text-pointer information, ignores image data, and creates a TextPointer object.

When a column contains a significant amount of image data, selecting the column for one or more rows and waiting to get all the data is likely to be inefficient, since the data is not used. To shortcut this process, use the set textsize command to minimize the amount of data returned in a packet. This code example for getting a TextPointer object includes the use of set textsize for this purpose.

/*
 * Define a string for selecting pic column data for author ID 
 * 899-46-2035.
 */
 String getColumnData = "select pic from au_pix where au_id = '899-46-2035'";
 
 /*
 * Use set textsize to return only a single byte of column data
 * to a Statement object. The packet with the column data will
 * contain the "hidden" information necessary for creating a
 * TextPointer object.
 */
 Statement stmt= connection.createStatement();
 stmt.executeUpdate("set textsize 1");
 
 /*
 * Select the column data into a ResultSet object--cast the 
 * ResultSet to SybResultSet because the getTextPtr method is 
 * in SybResultSet, which extends ResultSet.
 */
 SybResultSet rs = (SybResultSet)stmt.executeQuery(getColumnData);
 
 /*
 * Position the result set cursor on the returned column data 
 * and create the desired TextPointer object.
 */
 rs.next();
 TextPointer tp = rs.getTextPtr("pic");
 
 /* 
 * Now, assuming we are only updating one row, and won’t need
 * the minimum textsize set for the next return from the server,
 * we reset textsize to its default value.
 */
 stmt.executeUpdate("set textsize 0");