Using readtext on unitext columns  Aggregate functions

Chapter 15: Using the Built-In Functions in Queries

Examples of using text functions

This example uses the textptr function to locate the text column, copy, associated with title_id BU7832 in table blurbs. The text pointer, a 16-byte binary string, is put into a local variable, @val, and supplied as a parameter to the readtext command. readtext returns 5 bytes starting at the second byte, with an offset of 1.

declare @val binary(16) 
select @val = textptr(copy) from blurbs 
where au_id = "486-29-1786" 
readtext blurbs.copy @val 1 5

textptr returns a 16-byte varbinary string. Sybase suggests that you put this string into a local variable, as in the preceding example, and use it by reference.

An alternative to using textptr in the preceding declare example is the @@textptr global variable:

readtext texttest.blurb @@textptr 1 5

The value of @@textptr is set from the last insert or update to any text, unitext, or image field by the current Adaptive Server process. Inserts and updates by other processes do not affect the current process.

Explicit conversion using the convert function is supported from text to char, nchar, unichar, varchar, univarchar, or nvarchar, and from image to varbinary or binary. You are limited to the maximum length of the character datatype, which is determined by the maximum column size for your server’s logical page size. If you do not specify the datatype length, the default length of the converted value is 30 bytes.

Implicit conversion between text/image and unitext is also allowed. Conversion of text, unitext, or image to datatypes other than these is not supported, implicitly or explicitly.





Copyright © 2005. Sybase Inc. All rights reserved. Aggregate functions

View this book as PDF