background image
<< User-defined types | JDBC metadata type >>

XML data type

<< User-defined types | JDBC metadata type >>
Derby Reference Manual
204
VARCHAR
Derby does not pad a VARCHAR value whose length is less than specified. Derby
truncates spaces from a string value when a length greater than the VARCHAR expected
is provided. Characters other than spaces are not truncated, and instead cause an
exception to be raised. When
comparison boolean operators
are applied to VARCHARs,
the lengths of the operands are not altered, and spaces at the end of the values are
ignored.
When CHARs and VARCHARs are mixed in expressions, the shorter value is padded
with spaces to the length of the longer value.
The type of a string constant is CHAR, not VARCHAR.
VARCHAR FOR BIT DATA data type
The VARCHAR FOR BIT DATA type allows you to store binary strings less than or equal
to a specified length. It is useful for unstructured data where character strings are not
appropriate (e.g., images).
Syntax
{ VARCHAR | CHAR VARYING | CHARACTER VARYING } (length) FOR BIT DATA
length is an unsigned integer literal designating the length in bytes.
Unlike the case for the CHAR FOR BIT DATA type, there is no default length for a
VARCHAR FOR BIT DATA type. The maximum size of the length value is 32,672 bytes.
JDBC metadata type (java.sql.Types)
VARBINARY
VARCHAR FOR BIT DATA stores variable-length byte strings. Unlike CHAR FOR BIT
DATA values, VARCHAR FOR BIT DATA values are not padded out to the target length.
An operation on a VARCHAR FOR BIT DATA and a CHAR FOR BIT DATA value (e.g., a
concatenation) yields a VARCHAR FOR BIT DATA value.
The type of a byte literal is always a VARCHAR FOR BIT DATA, not a CHAR FOR BIT
DATA.
XML data type
The XML data type is used for Extensible Markup Language (XML) documents.
The XML data type is used:
· To store XML documents that conform to the SQL/XML definition of a well-formed
XML(DOCUMENT(ANY)) value.
· Transiently for XML(SEQUENCE) values, that might not be well-formed
XML(DOCUMENT(ANY)) values.
Note: For an application to retrieve, update, query, or otherwise access an XML
data value, the application must have classes for a JAXP parser and for Xalan in the
classpath. Derby issues an error if either the parser or Xalan is not found. In some
situations, you may need to take steps to place the parser and Xalan in your classpath.
See "XML data types and operators" in the Derby Developer's Guide for details.
Because none of the JDBC-side support for SQL/XML is implemented in Derby, it is not
possible to bind directly into an XML value or to retrieve an XML value directly from a
result set using JDBC. Instead, you must bind and retrieve the XML data as Java strings