bea.com | products | dev2dev | support | askBEA

Download Docs | Site Map | Glossary
Search

Building Queries and Data Views

Treat Functions

The treat functions process a source value as the argument and treat that source value as if it is the datatype in the treat function. These functions are used when mapping optional values (which do not have to have data associated with them) to mandatory values (which do have to have data associated with them). From the Query menu Automatic Treat As checkbox, you can set up the Data View Builder to automatically add treat functions when they are needed, or you can add them manually. Without the treat functions, some queries that attempt to map optional fields (for example, nullable relational database columns) to mandatory fields might fail.

Unlike the cast functions, the treat functions do not change the type of the input value; instead they ensure that an expression has the intended type when it is evaluated for query execution.

A typical use case is when you need to map elements from a nullable relational database column that you know do not contain any null values.

Another use case is where you need to map non-nullable (mandatory) elements to a function that produces optional (nullable) output. For example, if you map an xf:string type to a custom function that outputs an xf:string? type, and then map that output to an xf:string type, there will be a type mismatch which will cause the query to fail during compilation. The type mismatch is because the output type of the function is xf:string?, which mismatches xf:string. You can correct this by placing a treat as xs:string function betweenthe custom function and the output.

The following table describes Liquid Data data types that conform to the XQuery specification that you can use in treat as functions. For more information about data types, see the XQuery 1.0 and XPath 2.0 Functions and Operators specification. The following treat as functions are available:

- treat as xs:boolean

- treat as xs:byte

- treat as xs:date

- treat as xs:dateTime

- treat as xs:decimal

- treat as xs:double

- treat as xs:float

- treat as xs:int

- treat as xs:integer

- treat as xs:long

- treat as xs:short

- treat as xs:string

- treat as xs:time

treat as xs:boolean

Treats the input value as if it is a boolean value (true or false). Use to map optional boolean elements to mandatory boolean elements.

Data Types

- Input data type: xs:anyValue?

- Returned data type: xs:anyValue?

Notes

See Treat Functions.

XQuery Specification Compliance

Conforms to the current specification.

treat as xs:byte

Treats the input value as if it is a byte value. Use to map optional boolean elements to mandatory boolean elements.

Data Types

- Input data type: xs:anyValue?

- Returned data type: xs:anyValue?

Notes

See Treat Functions.

XQuery Specification Compliance

Conforms to the current specification.

treat as xs:date

Treats the input value as if it is a date value. Use to map optional boolean elements to mandatory boolean elements.

Data Types

- Input data type: xs:anyValue?

- Returned data type: xs:anyValue?

Notes

See Treat Functions.

XQuery Specification Compliance

Conforms to the current specification.

treat as xs:dateTime

Treats the input value as if it is a dateTime value. Use to map optional boolean elements to mandatory boolean elements.

Data Types

- Input data type: xs:anyValue?

- Returned data type: xs:anyValue?

Notes

See Treat Functions.

XQuery Specification Compliance

Conforms to the current specification.

treat as xs:decimal

Treats the input value as if it is a decimal value. Use to map optional boolean elements to mandatory boolean elements.

Data Types

- Input data type: xs:anyValue?

- Returned data type: xs:anyValue?

Notes

See Treat Functions.

XQuery Specification Compliance

Conforms to the current specification.

treat as xs:double

Treats the input value as if it is a double value. Use to map optional boolean elements to mandatory boolean elements.

Data Types

- Input data type: xs:anyValue?

- Returned data type: xs:anyValue?

Notes

This function uses the xf:double function.

XQuery Specification Compliance

- Liquid Data does not support not-a-number (NaN), -0, or the negative and positive infinity values -INF and INF.

- Liquid Data attempts to support any input value, instead of just string literals, and convert it at run time.

treat as xs:float

Treats the input value as if it is a float value. Use to map optional boolean elements to mandatory boolean elements.

Data Types

- Input data type: xs:anyValue?

- Returned data type: xs:anyValue?

Notes

See Treat Functions.

XQuery Specification Compliance

Conforms to the current specification.

treat as xs:int

Treats the input value as if it is a int value. Use to map optional boolean elements to mandatory boolean elements.

Data Types

- Input data type: xs:anyValue

- Returned data type: xs:int

Notes

This function uses the xf:int function.

XQuery Specification Compliance

Conforms to the current specification.

treat as xs:integer

Treats the input value as if it is a integer value. Use to map optional boolean elements to mandatory boolean elements.

Data Types

- Input data type: xs:anyValue?

- Returned data type: xs:anyValue?

Notes

See Treat Functions.

XQuery Specification Compliance

Conforms to the current specification.

treat as xs:long

Treats the input value as if it is a long value. Use to map optional boolean elements to mandatory boolean elements.

Data Types

- Input data type: xs:anyValue?

- Returned data type: xs:anyValue?

Notes

See Treat Functions.

XQuery Specification Compliance

Conforms to the current specification.

treat as xs:short

Treats the input value as if it is a short value. Use to map optional boolean elements to mandatory boolean elements.

Data Types

- Input data type: xs:anyValue?

- Returned data type: xs:anyValue?

Notes

See Treat Functions.

XQuery Specification Compliance

Conforms to the current specification.

treat as xs:string

Treats the input value as if it is a string value. Use to map optional boolean elements to mandatory boolean elements.

Data Types

- Input data type: xs:anyValue?

- Returned data type: xs:anyValue?

Notes

See Treat Functions.

XQuery Specification Compliance

Conforms to the current specification.

treat as xs:time

Treats the input value as if it is a time value. Use to map optional boolean elements to mandatory boolean elements.

Data Types

- Input data type: xs:anyValue?

- Returned data type: xs:anyValue?

Notes

See Treat Functions.

XQuery Specification Compliance

Conforms to the current specification.