EBCDIC_STR scalar function

The EBCDIC_STR function returns a string, in the system EBCDIC CCSID, that is an EBCDIC version of the string.

Read syntax diagramSkip visual syntax diagramEBCDIC_STR( string-expression)

The schema is SYSIBM.

The system EBCDIC CCSID is defined as the SBCS EBCDIC CCSID on a MIXED=NO system or the MIXED EBCDIC CCSID on a MIXED=YES system.

string-expression
An expression that returns a value of a built-in character or graphic string. If the string is a character string, it cannot be bit data. string-expression must be an ASCII, EBCDIC, or Unicode string. EBCDIC_STR returns an EBCDIC version of the string. Start of changeNon-EBCDIC characters other than the Unicode replacement character (X'EFBFBD' in UTF-8 encoding or X'FFFD' in UTF-16 encoding), are converted to the form \xxxx, where xxxx represents a UTF-16 code unit. The Unicode replacement character is converted to X'3F'.End of change

The argument can also be a numeric data type. The numeric argument is implicitly cast to a VARCHAR data type.

The length attribute of the result is calculated using the formulas in Table 5. The length attribute of the result will be MIN( ( 5*n),32704). Where n is the result of applying the formulas in Table 5 based on input and output data types.

The result of the function is an EBCDIC character string (in the system EBCDIC CCSID). If the actual length of the result string exceeds the maximum for the return type, an error occurs.

The result can be null; if the argument is null, the result is the null value.

Example: The following example returns the EBCDIC string equivalent of the text string "Hi my name is Андрей (Andrei)"

SET :HV1 = EBCDIC_STR('Hi, my name is Андрей (Andrei)');

HV1 is assigned the value "Hi, my name is \0410\043D\0434\0440\0435\0439 (Andrei)"