15.00 - IS UNTIL_CHANGED/IS NOT UNTIL_CHANGED - Teradata Database

Teradata Database SQL Functions, Operators, Expressions, and Predicates

Product
Teradata Database
Release Number
15.00
Content Type
Programming Reference
Publication ID
B035-1145-015K
Language
English (United States)

IS UNTIL_CHANGED/IS NOT UNTIL_CHANGED

Purpose  

Tests whether the ending bound value of a Period expression or a derived period IS UNTIL_CHANGED or IS NOT UNTIL_CHANGED.

Syntax  

where:

 

Syntax element …

Specifies …

period_expression

any expression that evaluates to a Period data type, including:

  • PERIOD(TIMESTAMP WITH TIME ZONE)
  • PERIOD(TIMESTAMP)
  • PERIOD(DATE) type
  • derived_period

    any expression that evaluates to a derived period.

    Usage Notes  

    You can only compare UNTIL_CHANGED to the ending bound of a Period value with an element type of DATE or TIMESTAMP WITH TIME ZONE. Therefore, the result type of the END function must be DATE or TIMESTAMP WITH TIME ZONE. For information about the END function, see “END” on page 1066.

    In comparisons, the precision of the UNTIL_CHANGED value is truncated to the precision of the ending bound value being compared. That is, the number of digits after the decimal point for UNTIL_CHANGED depends upon the precision of the ending bound to which it is compared. The time zone is omitted if the ending bound value has no time zone.

    If the ending bound value is NULL, IS [NOT] UNTIL_CHANGED returns UNKNOWN.

    You cannot use IS [NOT] UNTIL_CHANGED on the ending bound of a system-time or temporal table columns.

    For information on using TEMPORAL_TIMESTAMP with temporal tables, see ANSI Temporal Table Support and Temporal Table Support.

    Example  

    Consider the following employee table, where the column eduration is defined as a PERIOD(DATE) data type:

       ename               eid  eduration
       ----------  -----------  ------------------------
       Adams            210677  ('05/03/01', '06/05/21')
       Gunther          199347  ('04/06/06', '99/12/31')
       Montoya          199340  ('04/06/02', '99/12/31')
       Chan             210427  ('04/09/24', '99/12/31')
       Fuller           197899  ('03/05/27', '03/11/30')

    The following SQL query uses IS UNTIL_CHANGED to compare the ending bound value of the eduration column to UNTIL_CHANGED:

       SELECT ename, eid
       FROM employee
       WHERE END(eduration) IS UNTIL_CHANGED;

    The result is:

       ename               eid
       ----------  -----------
       Gunther          199347
       Montoya          199340
       Chan             210427

    Example  

    If we assume that the employee table, created by the following SQL statement:

    CREATE MULTISET TABLE employee(empno    INTEGER,
                                   ename    VARCHAR(50),
                                   deptno   INTEGER,
                                   jobstart DATE NOT NULL,
                                   jobend   DATE NOT NULL,
                                   PERIOD FOR jobduration(jobstart, jobend))
                                   PRIMARY INDEX(empno);

    contains the following row:

    INSERT INTO employee(1025, 'John', '999', DATE'2005-02-03', UNTIL_CHANGED);

    The following SELECT statement:

    SELECT empno,ename(CHAR(30)) FROM employee WHERE END(jobduration) IS UNTIL_CHANGED;

    returns:

     empno ename
    ------ ------
      1025   John