Skip navigation links

Oracle® OLAP Java API Reference
11g Release 2 (11.2)

E10794-05


oracle.olapi.syntax
Class IntervalLiteralExpression

java.lang.Object
  extended by oracle.olapi.syntax.SyntaxObject
      extended by oracle.olapi.syntax.DataObject
          extended by oracle.olapi.syntax.Expression
              extended by oracle.olapi.syntax.TypedExpression
                  extended by oracle.olapi.syntax.RowExpression
                      extended by oracle.olapi.syntax.IntervalLiteralExpression

All Implemented Interfaces:
FunctionArgument

public final class IntervalLiteralExpression
extends RowExpression

A RowExpression that represents an interval literal expression, which is similar to a SQL interval literal expression. An interval literal specifies a period of time. You can specify the time period in years and months, or in days, hours, minutes, and seconds.

Oracle Database supports two types of interval literals, YEAR TO MONTH and DAY TO SECOND. Each type contains a leading period and a trailing period. The leading period defines the basic unit of date or time being measured. The trailing period defines the smallest increment of the basic unit being considered. For example, a YEAR TO MONTH interval considers an interval of years to the nearest month. A DAY TO SECOND interval literal can specify various combinations of intervals, such as DAY TO MINUTE, which considers an interval of days to the nearest minute.

For all interval literals, the leading period must specify a larger time unit than time unit of the trailing period. If you have date data in numeric form, then you can use the NUMTOYMINTERVAL or NUMTODSINTERVAL conversion function to convert the numeric data into interval values. Interval literals are used primarily with analytic functions.

For more information, see Interval Literals in Oracle Database SQL Language Reference.


Field Summary
static java.lang.String DAY
          A constant that represents a DAY period.
static int DEFAULT_FRACTIONAL_SECONDS_PRECISION
          A constant that represents a default value for the precision of the fractional seconds for a leading or trailing SECOND period.
static int DEFAULT_LEADING_PRECISION
          A constant that represents a default value for the precision of the leading period.
static java.lang.String HOUR
          A constant that represents a HOUR period.
static java.lang.String MINUTE
          A constant that represents a MINUTE period.
static java.lang.String MONTH
          A constant that represents a MONTH period.
static java.lang.String SECOND
          A constant that represents a SECOND period.
static java.lang.String YEAR
          A constant that represents a YEAR period.

 

Constructor Summary
IntervalLiteralExpression(java.lang.String value, java.lang.String leadingPeriod, int leadingPrecision, int leadingFractionalSecondsPrecision, java.lang.String trailingPeriod, int trailingFractionalSecondsPrecision)
          Creates an IntervalLiteralExpression that has the specified value, periods, and precisions.
IntervalLiteralExpression(java.lang.String value, java.lang.String leadingPeriod, int leadingPrecision, java.lang.String trailingPeriod)
          Creates an IntervalLiteralExpression that has the specified value, periods, and precision.
IntervalLiteralExpression(java.lang.String value, java.lang.String leadingPeriod, java.lang.String trailingPeriod)
          Creates an IntervalLiteralExpression that has the specified value and periods.

 

Method Summary
 int getLeadingFractionalSecondsPrecision()
          Gets the fractional seconds precision for the value for the leading seconds period of this IntervalLiteralExpression.
 java.lang.String getLeadingPeriod()
          Gets the type of the leading time period of this IntervaLiterallExpression.
 int getLeadingPrecision()
          Gets the precision for the value for the leading period of this IntervalLiteralExpression.
 int getTrailingFractionalSecondsPrecision()
          Gets the fractional seconds precision of the value for the trailing seconds period of this IntervalLiteralExpression.
 java.lang.String getTrailingPeriod()
          Gets the type of the trailing time period of this IntervaLiterallExpression.
 java.lang.String getValue()
          Gets the values for the leading and trailing periods of this IntervaLiterallExpression.
 java.lang.Object visit(SyntaxObjectVisitor visitor, java.lang.Object context)
          Calls the visitIntervalLiteralExpression method of the SyntaxObjectVisitor and passes that method this IntervalLiteralExpression and an Object.

 

Methods inherited from class oracle.olapi.syntax.RowExpression
isCompositeObject

 

Methods inherited from class oracle.olapi.syntax.TypedExpression
abs, acos, addMonths, addMonths, ascii, asciiStr, asin, atan, atan2, between, binToNum, bitAnd, cast, ceil, charToROWID, chr, chr, coalesce, compose, concat, concat, convert, convert, cos, cosh, currentDate, currentTime, dbTimeZone, decode, decompose, deref, div, div, div, div, div, dump, eq, eq, eq, eq, eq, exp, extractDay, extractHour, extractMinute, extractMonth, extractSecond, extractTimeZoneAbbr, extractTimeZoneHour, extractTimeZoneMinute, extractTimeZoneRegion, extractYear, floor, fromTZ, ge, ge, ge, ge, ge, getDataType, greatest, gt, gt, gt, gt, gt, hexToRAW, in, initcap, instr, instr2, instr4, instrB, instrC, isInfinite, isNAN, isNotNull, isNull, lastDay, le, le, le, le, le, least, length, length2, length4, lengthB, lengthC, like, like, like2, like4, likeC, ln, localTimestamp, log, lower, lpad, lt, lt, lt, lt, lt, ltrim, minus, minus, minus, minus, minus, minus, mod, monthsBetween, nanvl, ne, ne, ne, ne, ne, newTime, nextDay, nlsCharsetDeclLen, nlsCharsetID, nlsCharsetName, nlsInitcap, nlsLower, nlsSort, nlsUpper, notIn, nullIf, numToDSInterval, numToYMInterval, nvl, nvl2, oraHash, plus, plus, plus, plus, plus, power, rawToHex, rawToNHex, regexpInstr, regexpReplace, regexpSubstr, remainder, replace, round, rowIDToChar, rowIDToNChar, rpad, rtrim, scnToTimestamp, sessionTimeZone, sign, sin, sinh, soundex, sqrt, substr, substr2, substr4, substrB, substrC, sysContext, sysDate, sysExtractUTC, sysGUID, sysTimestamp, sysTypeID, tan, tanh, times, times, times, times, times, timestampToSCN, toBinaryDouble, toBinaryFloat, toChar, toChar, toCLOB, toDate, toDate, toDSInterval, toLOB, toMultiByte, toNChar, toNChar, toNCLOB, toNumber, toNumber, toNumber, toSingleByte, toTimestamp, toTimestampTZ, toYMInterval, translate, translateUsingCharCS, translateUsingNCharCS, treat, trim, trimLeading, trimTrailing, trunc, tzOffset, UID, unistr, upper, USER, userEnv, vsize, widthBucket

 

Methods inherited from class oracle.olapi.syntax.SyntaxObject
equals, equals, fromSyntax, fromSyntax, fromSyntax, fromSyntax, fromSyntax, isValid, toSyntax, toSyntax, toSyntax, toSyntax, toSyntax, toSyntax

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

DAY

public static final java.lang.String DAY
A constant that represents a DAY period.
See Also:
Constant Field Values

HOUR

public static final java.lang.String HOUR
A constant that represents a HOUR period.
See Also:
Constant Field Values

MINUTE

public static final java.lang.String MINUTE
A constant that represents a MINUTE period.
See Also:
Constant Field Values

SECOND

public static final java.lang.String SECOND
A constant that represents a SECOND period.
See Also:
Constant Field Values

YEAR

public static final java.lang.String YEAR
A constant that represents a YEAR period.
See Also:
Constant Field Values

MONTH

public static final java.lang.String MONTH
A constant that represents a MONTH period.
See Also:
Constant Field Values

DEFAULT_LEADING_PRECISION

public static final int DEFAULT_LEADING_PRECISION
A constant that represents a default value for the precision of the leading period.
See Also:
Constant Field Values

DEFAULT_FRACTIONAL_SECONDS_PRECISION

public static final int DEFAULT_FRACTIONAL_SECONDS_PRECISION
A constant that represents a default value for the precision of the fractional seconds for a leading or trailing SECOND period.
See Also:
Constant Field Values

Constructor Detail

IntervalLiteralExpression

public IntervalLiteralExpression(java.lang.String value,
                                 java.lang.String leadingPeriod,
                                 int leadingPrecision,
                                 int leadingFractionalSecondsPrecision,
                                 java.lang.String trailingPeriod,
                                 int trailingFractionalSecondsPrecision)
Creates an IntervalLiteralExpression that has the specified value, periods, and precisions. The following are examples of using this constructor.
 IntervalLiteralExpression intLitExpr = new IntervalLiteralExpression(
                                          "200 5:12:10:222",
                                          IntervalLiteralExpression.DAY, 
                                          3,
          IntervalLiteralExpression.DEFAULT_FRACTIONAL_SECONDS_PRECISION,
                                        IntervalLiteralExpression.SECOND, 
                                          3);
 System.out.println("The syntax of intLitExpr is " + 
                     intLitExpr.toSyntax());
 System.out.println("The data type of intLitExpr is " + 
                     intLitExpr.getDataType().getName());

 IntervalLiteralExpression intLitExpr2 = new IntervalLiteralExpression(
                                           "11:12:10.1234567",
                                           IntervalLiteralExpression.HOUR, 
                      IntervalLiteralExpression.DEFAULT_LEADING_PRECISION,
           IntervalLiteralExpression.DEFAULT_FRACTIONAL_SECONDS_PRECISION,
                                         IntervalLiteralExpression.SECOND, 
                                           7);
 System.out.println("The syntax of intLitExpr2 is " + 
                     intLitExpr2.toSyntax());
 System.out.println("The data type of intLitExpr2 is " + 
                     intLitExpr2.getDataType().getName());
The output of the examples is the following.
 The syntax of intLitExpr is INTERVAL '200 5:12:10:222' DAY(3) TO SECOND (3)
 The data type of intLitExpr is INTERVAL DAY TO SECOND
 The syntax of intLitExpr2 is INTERVAL '11:12:10.1234567' HOUR TO SECOND (7)
 The data type of intLitExpr2 is INTERVAL DAY TO SECOND
Parameters:
value - A String that contains values for the leading and trailing time periods.
leadingPeriod - One of the constants of this class that specifies the type of leading time period.
leadingPrecision - An integer that specifies the precision of the value of the leading time period.
leadingFractionalSecondsPrecision - An integer that specifies the precision of the value of the leading seconds time period.
trailingPeriod - One of the constants of this class that specifies the type of trailing time period, which must be less significant than the leading period.
trailingFractionalSecondsPrecision - An integer that specifies the precision of the value of the trailing seconds time period.

IntervalLiteralExpression

public IntervalLiteralExpression(java.lang.String value,
                                 java.lang.String leadingPeriod,
                                 int leadingPrecision,
                                 java.lang.String trailingPeriod)
Creates an IntervalLiteralExpression that has the specified value, periods, and precision. The following is an example of using this constructor.
 IntervalLiteralExpression intLitExpr3 = new IntervalLiteralExpression(
                                          "123-2",
                                          IntervalLiteralExpression.YEAR,
                                          3,
                                          IntervalLiteralExpression.MONTH);
 System.out.println("The syntax of intLitExpr3 is " + 
                     intLitExpr3.toSyntax());
 System.out.println("The data type of intLitExpr3 is " + 
                     intLitExpr3.getDataType().getName());
The output of the example is the following.
 The syntax of intLitExpr3 is INTERVAL '123-2' YEAR(3) TO MONTH
 The data type of intLitExpr3 is INTERVAL YEAR TO MONTH
Parameters:
value - A String that contains values for the leading and trailing time periods.
leadingPeriod - One of the constants of this class that specifies the type of leading time period.
trailingPeriod - One of the constants of this class that specifies the type of trailing time period, which must be less significant than the leading period.
leadingPrecision - An integer that specifies the precision of the value of the leading time period.

IntervalLiteralExpression

public IntervalLiteralExpression(java.lang.String value,
                                 java.lang.String leadingPeriod,
                                 java.lang.String trailingPeriod)
Creates an IntervalLiteralExpression that has the specified value and periods. The following are examples of using this constructor.
 IntervalLiteralExpression intLitExpr4 = new IntervalLiteralExpression(
                                          IntervalLiteralExpression.YEAR, 
                                          IntervalLiteralExpression.MONTH, 
                                          "12-9");
 System.out.println("The syntax of intLitExpr4 is " + 
                     intLitExpr4.toSyntax());
 System.out.println("The data type of intLitExpr4 is " + 
                     intLitExpr4.getDataType().getName());
                    
 IntervalLiteralExpression intLitExpr5 = new IntervalLiteralExpression(
                                          IntervalLiteralExpression.MINUTE, 
                                          IntervalLiteralExpression.SECOND, 
                                          "10:22");
 System.out.println("The syntax of intLitExpr5 is " + 
                     intLitExpr5.toSyntax());
 System.out.println("The data type of intLitExpr5 is " + 
                    intLitExpr5.getDataType().getName());
The output of the examples is the following.
 The syntax of intLitExpr4 is INTERVAL '12-9' YEAR TO MONTH
 The data type of intLitExpr4 is INTERVAL YEAR TO MONTH
 The syntax of intLitExpr5 is INTERVAL '10:22' MINUTE TO SECOND
 The data type of intLitExpr5 is INTERVAL DAY TO SECOND
Parameters:
value - A String that contains values for the leading and trailing time periods.
leadingPeriod - One of the constants of this class that specifies the type of leading time period.
trailingPeriod - One of the constants of this class that specifies the type of trailing time period, which must be less significant than the leading period.

Method Detail

visit

public java.lang.Object visit(SyntaxObjectVisitor visitor,
                              java.lang.Object context)
Calls the visitIntervalLiteralExpression method of the SyntaxObjectVisitor and passes that method this IntervalLiteralExpression and an Object.
Specified by:
visit in class SyntaxObject
Parameters:
visitor - A SyntaxObjectVisitor.
context - An Object.
Returns:
The Object returned by the visitIntervalLiteralExpression method.

getLeadingPeriod

public java.lang.String getLeadingPeriod()
Gets the type of the leading time period of this IntervaLiterallExpression.
Returns:
A String that contains the leading time period of this IntervaLiterallExpression, which is the value of one of the constants of this class.

getTrailingPeriod

public java.lang.String getTrailingPeriod()
Gets the type of the trailing time period of this IntervaLiterallExpression.
Returns:
A String that contains the trailing time period of this IntervaLiterallExpression, which is the value of one of the constants of this class.

getValue

public java.lang.String getValue()
Gets the values for the leading and trailing periods of this IntervaLiterallExpression. The values specify the number of units of the periods.
Returns:
A String that contains values that specify the number of units for the leading and trailing time periods.

getLeadingPrecision

public int getLeadingPrecision()
Gets the precision for the value for the leading period of this IntervalLiteralExpression.
Returns:
A TypedExpression that resolves to an integer value.

getLeadingFractionalSecondsPrecision

public int getLeadingFractionalSecondsPrecision()
Gets the fractional seconds precision for the value for the leading seconds period of this IntervalLiteralExpression.
Returns:
An integer that is the precision of the fractional seconds of the leading seconds time period.

getTrailingFractionalSecondsPrecision

public int getTrailingFractionalSecondsPrecision()
Gets the fractional seconds precision of the value for the trailing seconds period of this IntervalLiteralExpression.
Returns:
An integer that is the precision of the fractional seconds of the trailing seconds time period.

Skip navigation links

Copyright © 2002, 2010, Oracle. All rights reserved.