CAST function

CAST is a complex function that transforms one or more values from one data-type into another.

SYNTAX

CAST transforms the value of one data-type into another data-type. precision and scale can be integer literals only. Expressions are not supported. For a description of precision, scale, and interval_qualifier, see ESQL data types.

Start of changeNot all conversions are supported; see Supported casts for a list of supported conversions.End of change

Parameters

Source expression

CAST returns its first parameter (source_expression) as the data-type specified by its second parameter (DataType). In all cases, if the source expression is NULL, the result is NULL. If the evaluated source expression is not compatible with the target data-type, or if the source expression is of the wrong format, a runtime error is generated.

CCSID

Start of changeThe CCSID clause is used only for conversions to or from one of the string data-types. It allows you to specify the code page of the source or target string. End of change

The CCSID expression can be any expression evaluating to a value of type INT. It is interpreted according to normal WebSphere Business Integration Message Broker rules for CCSIDs. Start of changeSee Supported code pages for a list of valid values.End of change

ENCODING

The ENCODING clause allows you to specify the encoding. It is used for certain conversions only. The ENCODING value can be any expression evaluating to a value of type INT. It is interpreted according to normal WebSphere Business Integration Message Broker rules for encoding. Valid values are:
  • MQENC_NATIVE (0x00000222L)
  • MQENC_INTEGER_NORMAL (0x00000001L)
  • MQENC_INTEGER_REVERSED (0x00000002L)
  • MQENC_DECIMAL_NORMAL (0x00000010L)
  • MQENC_DECIMAL_REVERSED (0x00000020L)
  • MQENC_FLOAT_IEEE_NORMAL (0x00000100L)
  • MQENC_FLOAT_IEEE_REVERSED (0x00000200L)
  • MQENC_FLOAT_S390 (0x00000300L)