Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 3 Tools : $TYPECAST

$TYPECAST
Converts a variable according to the arguments supplied. (F)
Invocation
result = $TYPECAST(type, syntax, size, decimals, value)
 
The semantic type to be used. This is a typeless 1‑byte identifier of character syntax.
The syntax to be used. This is a typeless 3‑byte identifier of character syntax.
The size to be used. This is a typeless 2‑byte identifier of binary syntax with 0 decimal places. The size value must be greater than zero.
The decimals value to be used. This is a typeless 2‑byte identifier of binary syntax with 0 decimal places. The decimals value must be greater than or equal to zero and must be consistent with the syntax requested.

Exceptions
 
Signaled if any of the input arguments type, syntax, size, or decimals is invalid.
Example
Rule

 
RULE EDITOR ===> SCROLL: P
COERCE_ASSIGN(TO_TABLE, TO_FIELD, FROM_TABLE, FROM_FIELD);
_
_ ---------------------------------------------------------------------------
_ ------------------------------------------------------------+--------------
_ GET FIELDS(TO_TABLE) WHERE NAME = TO_FIELD; | 1
_ (TO_TABLE).(TO_FIELD) = $TYPECAST(FIELDS.TYPE, | 2
_ FIELDS.SYNTAX, FIELDS.LENGTH, FIELDS.DECIMAL, |
_ (FROM_TABLE).(FROM_FIELD)); |
_ |
_ |
_ ---------------------------------------------------------------------------
_

 
Explanation
This rule assigns a field of a table to another field of another table, if there exists an allowed conversion between the source value and the destination value, irrespective of their semantic types. For example, binary quantity values can be assigned to binary identifier fields and binary date values to quantity binary fields. Assignments such as assigning a string containing letters to a numerical fields are not allowed.
CALL COERCE_ASSIGN('T1', 'CB4', 'T2', 'DB4');
performs this assignment:
T1.CB4 = T2.DB4;
ignoring the semantic type prohibition against it and leaving T1.CB4 with the internal representation of the date in field T2.DB4 (assuming that CB4 is a binary count field of length 4 and DB4 is a binary date field of length 4).
Refer to TIBCO Object Service Broker Programming in Rules for allowed arithmetic conversions.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved