bea.com | products | dev2dev | support | askBEA
 Download Docs   Site Map   Glossary 
Search

Building Queries and Data Views

 Previous Next Contents Index View as PDF  

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

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

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

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

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

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

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

Notes

This function uses the xf:double function.

XQuery Specification Compliance

 


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

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

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

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

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

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

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

Notes

See Treat Functions.

XQuery Specification Compliance

Conforms to the current specification.

 

Back to Top Previous Next