NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
C-162
CURRENT Function
The following statement creates a view that joins the CUSTOMER and ORDERS
tables in a better way than in the previous example. The CREATE VIEW statement
uses a WHERE clause to join the two tables only at rows in which CUSTNUM
values are equal. The view can never contain more rows than the number of rows in
the largest table.
CREATE VIEW GOOD
(C_CUSTNUM,O_CUSTNUM,CUSTNAME,STATE,ORDERNUM)
AS SELECT C.CUSTNUM,O.CUSTNUM,CUSTNAME,STATE,ORDERNUM
FROM SALES.CUSTOMER C, SALES.ORDERS O
WHERE C.CUSTNUM = O.CUSTNUM CATALOG SALES;
See Joins on page J-1 or the NonStop SQL/MP Query Guide for more information
about join methods.
CURRENT Function
CURRENT is a function that returns the current local date, time, or both as a value of
type DATETIME.
SQL evaluates CURRENT only once in an SQL statement. If you use CURRENT more
than once in the same statement, each reference returns the same value.
[start-date-time TO ] end-date-time
specifies the range of DATETIME fields on which CURRENT operates. The default
is YEAR TO FRACTION(6).
CURRENT [ [start-date-time TO ] end-date-time]
start-date-time is:
{ YEAR }
{ MONTH }
{ DAY }
{ HOUR }
{ MINUTE }
{ SECOND }
{ FRACTION }
end-date-time is:
{ YEAR }
{ MONTH }
{ DAY }
{ HOUR }
{ MINUTE }
{ SECOND }
{ FRACTION [ (precision) ] }