Name

blob_to_string — Convert a blob to string

Synopsis

varchar blob_to_string ( in blob any );

Description

Although primarily used for converting blobs ( long varbinary , long varchar ) to string , blob_to_string may also be used to convert from wide string , persistent XML (XPER) and string_output streams . If the data being converted is longer than maximum length of a string , blob_to_string will signal an error.

[Note] Note

This function is equivalent to

cast (x as varchar)

. Using cast is preferred.

Parameters

blob

blob handle (long varbinary or long varchar), string_output or XPER (persistent XML)

Return Types

Varchar contents of blob .

Errors

Table24.6.Errors signalled by blob_to_string

SQLState Error Code Error Message Description
22023 SR068 XML tree cannot be used as argument of blob_to_string
22001 SR069 Attempt to convert a persistent XML document longer than VARCHAR maximum in blob_to_string
22023 SR070 blob_to_string requires a blob as argument
22023 SR071 Blob argument to blob_to_string must be a non-interactive blob
22001 SR072 Blob too long for the string.

Examples

Example24.28.Various conversions

SQL> use Demo;

Done. -- 20 msec.
SQL> select blob_to_string (Description) from Categories;
callret
VARCHAR
_______________________________________________________________________________

Soft drinks, coffees, teas, beers, and ales
Sweet and savory sauces, relishes, spreads, and seasonings
Desserts, candies, and sweet breads
Cheeses
Breads, crackers, pasta, and cereal
Prepared meats
Dried fruit and bean curd
Seaweed and fish

8 Rows. -- 37 msec.
SQL>


See Also

Casting , string_output .