C Data Type Definition
typedef int PDT_HANDLE;
Usage
Use the PDT_HANDLE data type when passing or returning a PERIOD(DATE), PERIOD(TIME(n)), PERIOD(TIME(n) WITH TIME ZONE), PERIOD(TIMESTAMP(n)), or PERIOD(TIMESTAMP(n) WITH TIME ZONE)) argument or return type.
The fractional seconds precision defined for the SQL PERIOD(TIME(n)), PERIOD(TIME(n) WITH TIME ZONE), PERIOD(TIMESTAMP(n)), or PERIOD(TIMESTAMP(n) WITH TIME ZONE)) type applies to the input arguments and return argument of a function. A value outside the valid range of values produces an error.
All PERIOD(TIME(n)) and PERIOD(TIMESTAMP(n)) values passed to a UDF are in Universal Coordinated Time (UTC), and all PERIOD(TIME(n)) and PERIOD(TIMESTAMP(n)) values that are returned from a UDF must be in UTC.
The PERIOD(TIME(n) WITH TIME ZONE) and PERIOD(TIMESTAMP(n) WITH TIME ZONE) types have time zone fields, zone_hour and zone_minute, that have an internal form and an external form. When input arguments with these types are passed to a UDF, the values must be in internal form. Similarly, return arguments with these types must be in internal form.
TIMEZONE_INTERNAL_TO_EXTERNAL(i, s, h, m)
TIMEZONE_EXTERNAL_TO_INTERNAL(s, h, m, i)
- i
- Pointer to either an ANSI_Time_Wzone or ANSI_TimeStamp_Wzone.
- s
- BYTEINT value to store the sign of i: 0 if h and m are negative and 1 if the they are positive.
- h
- BYTEINT value to store the hour offset of i.
- m
- BYTEINT value to store the minute offset of i.
The largest value for negative offsets is -12:59. The largest value for positive offsets is +14:00.
This representation results in two representations of UTC, that is +00:00 and -00:00. This mirrors the internal representation which uses both representations for display purposes.
For details on Period types, see Teradata Vantageā¢ - Data Types and Literals, B035-1143.
Here is an example using a PERIOD(DATE) in a UDF definition and PDT_HANDLE in a C function declaration.
SQL Function Definition | Equivalent C Function Declaration |
---|---|
CREATE FUNCTION F1 ( A PERIOD(DATE) ) RETURNS PERIOD(DATE) ...; |
void f1( PDT_HANDLE *a, PDT_HANDLE *result, ... ) { ... } |