SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
I-19
INTERVAL Data Type
In this example, CUSTLIST is a protection view of all columns of the CUSTOMER
table except the credit rating.
Suppose that one of your suppliers has become a customer. If you can use the
same number for both the customer and supplier numbers, you can select the
supplier information from the SUPPLIER table and insert it in the CUSTOMER
table through the CUSTLIST view. This operation works because the columns of
the SUPPLIER table contain values that correspond to the columns of the
CUSTLIST view. If you want a credit rating that is different from the default, you
must update the row.
VOLUME $VOL1.SALES;
INSERT INTO CUSTLIST
( SELECT * FROM INVENT.SUPPLIER WHERE SUPPNUM = 10 );
UPDATE CUSTOMER SET CREDIT = "A4" WHERE CUSTNUM = 10;
INTERVAL Data Type
INTERVAL values represent durations of time in year-month units (years and months),
in day-time units (days, hours, minutes, seconds, and fractions of a second), or in
subsets of those units.
No INTERVAL unit exists to bridge a year-month interval or a day-time interval
because the varying number of days in a month makes conversion on a duration basis
inexact.
INTERVAL { start-ym } [ (digits) ] [ TO end-ym ]
{ start-dt } [ TO end-dt ]
start-ym and end-ym are:
{ YEAR }
{ MONTH }
but the start-ym you specify must precede the end-ym you
specify in the list.
start-dt and end-dt are:
{ DAY }
{ HOUR }
{ MINUTE }
{ SECOND }
{ FRACTION [ ( precision ) ] }
but the start-dt you specify must precede the end-dt you
specify in the list, and only end-dt can include the
precision option for FRACTION.