%Cast meta-SQL element

Syntax


%Cast
(
source_expr
, 
source_type
, 
target_type
[, 
precision
[
.
scale
]])

Description

Use the %Cast meta-SQL function to convert a PeopleSoft data type to a Character data type. A database-generated error is returned if the function attempts to make an invalid conversion. %Cast can be used wherever %DateOut, %TimeOut, %DateTimeOut, %CurrentDateOut, %CurrentTimeOut, %CurrentDateTimeOut, and %NumToChar functions can be used.

Note:

%NumToChar will preserve all trailing zeroes. Therefore, use the scale parameter of %Cast to specify the number of trailing zeroes.

On some platforms the meta-SQL functions %DateOut, %TimeOut, %DateTimeOut, %CurrentDateOut, %CurrentTimeOut and %CurrentDateTimeOut don’t return a Character value. On other platforms, these functions return a Character string only in certain cases. %Cast returns a Character value on all supported platforms.

Use %Cast only in the Select portion of query. Do not use it in a Where clause or in Insert or Update statements.

Parameters

Parameter Description

source_expr

Specify the input expression in the form of a Number, Long Character, Date, Time, or DateTime column name or as a %CurrentDateOut, %CurrentTimeOut, or %CurrentDateTimeOut meta-SQL variable.

This parameter is not case sensitive.

source_type

Specify the source data type. Valid data types are Number, Long, Date, Time, and DateTime.

This parameter is not case sensitive.

target_type

Currently the only target type supported is Character.

precision . scale

The precision . scale parameter is currently supported on DB2 for z/OS only and with a source type of Number. While this parameter can be supplied on other platforms, it is ignored.

This parameter is optional.

The scale parameter is an optional part of this parameter. Therefore, the expression precision .0 is equivalent to precision .