Skip to content

Commit 82c9015

Browse files
gavinkinglukasj
authored andcommitted
specify JPAQL EXTRACT function
see #102
1 parent 21f02c8 commit 82c9015

File tree

1 file changed

+69
-9
lines changed

1 file changed

+69
-9
lines changed

spec/src/main/asciidoc/ch04-query-language.adoc

Lines changed: 69 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,9 @@ CHAR_LENGTH, CHARACTER_LENGTH, POSITION, and UNKNOWN are not currently
320320
used: they are reserved for future use.],
321321
BOTH, BY, CASE, CHAR_LENGTH, CHARACTER_LENGTH, CLASS, COALESCE, CONCAT,
322322
COUNT, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, DELETE, DESC,
323-
DISTINCT, ELSE, EMPTY, END, ENTRY, ESCAPE, EXISTS, FALSE, FETCH, FROM,
324-
FUNCTION, GROUP, HAVING, IN, INDEX, INNER, IS, JOIN, KEY, LEADING, LEFT,
325-
LENGTH, LIKE, LOCATE, LOWER, MAX, MEMBER, MIN, MOD, NEW, NOT, NULL,
323+
DISTINCT, ELSE, EMPTY, END, ENTRY, ESCAPE, EXISTS, EXTRACT, FALSE, FETCH,
324+
FROM, FUNCTION, GROUP, HAVING, IN, INDEX, INNER, IS, JOIN, KEY, LEADING,
325+
LEFT, LENGTH, LIKE, LOCATE, LOWER, MAX, MEMBER, MIN, MOD, NEW, NOT, NULL,
326326
NULLIF, OBJECT, OF, ON, OR, ORDER, OUTER, POSITION, SELECT, SET, SIZE,
327327
SOME, SQRT, SUBSTRING, SUM, THEN, TRAILING, TREAT, TRIM, TRUE, TYPE,
328328
UNKNOWN, UPDATE, UPPER, VALUE, WHEN, WHERE.
@@ -1697,7 +1697,8 @@ functions_returning_numerics ::=
16971697
SQRT(arithmetic_expression) |
16981698
MOD(arithmetic_expression, arithmetic_expression) |
16991699
SIZE(collection_valued_path_expression) |
1700-
INDEX(identification_variable)
1700+
INDEX(identification_variable) |
1701+
extract_datetime_field
17011702
----
17021703

17031704
The ABS function takes a numeric argument and
@@ -1738,11 +1739,62 @@ AND INDEX(w) = 0
17381739
functions_returning_datetime :=
17391740
CURRENT_DATE |
17401741
CURRENT_TIME |
1741-
CURRENT_TIMESTAMP
1742+
CURRENT_TIMESTAMP |
1743+
extract_datetime_part
17421744
----
17431745

1744-
The datetime functions return the value of
1745-
current date, time, and timestamp on the database server.
1746+
The functions CURRENT_DATE, CURRENT_TIME, and CURRENT_TIMESTAMP
1747+
return the value of the current date, time, or timestamp on the database
1748+
server, respectively.
1749+
1750+
The EXTRACT function takes a datetime argument and one of the following
1751+
field type identifiers: YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE,
1752+
SECOND, DATE, TIME.
1753+
1754+
EXTRACT returns the value of the corresponding field or part of the
1755+
datetime.
1756+
1757+
----
1758+
extract_datetime_field :=
1759+
EXTRACT(datetime_field FROM datetime_expression)
1760+
1761+
datetime_field := identification_variable
1762+
----
1763+
1764+
For the following field type identifiers, EXTRACT returns an integer
1765+
value:
1766+
1767+
- YEAR means the calendar year.
1768+
- QUARTER means the calendar quarter, numbered from 1 to 4.
1769+
- WEEK means the ISO-8601 week number.
1770+
- DAY means the calendar day of the month, numbered from 1.
1771+
- HOUR means the hour of the day in 24-hour time, numbered from 0 to 23.
1772+
- MINUTE means the minute of the hour, numbered from 0 to 59.
1773+
- SECOND means the second of the minute, numbered from 0 to 59.
1774+
1775+
It is illegal to pass a datetime argument which does not have the given
1776+
field type to EXTRACT.
1777+
1778+
----
1779+
extract_datetime_part :=
1780+
EXTRACT(datetime_part FROM datetime_expression)
1781+
1782+
datetime_part := identification_variable
1783+
----
1784+
1785+
For the following field type identifiers, EXTRACT returns a part of the
1786+
datetime value:
1787+
1788+
- DATE means the date part of a datetime.
1789+
- TIME means the time part of a datetime.
1790+
1791+
It is illegal to pass a datetime argument which does not have the given
1792+
part to EXTRACT.
1793+
1794+
[source,sql]
1795+
----
1796+
FROM Course c WHERE c.year = EXTRACT(YEAR FROM CURRENT_DATE)
1797+
----
17461798

17471799
===== Invocation of Predefined and User-defined Database Functions [[a5311]]
17481800

@@ -3001,11 +3053,13 @@ functions_returning_numerics ::=
30013053
SQRT(arithmetic_expression) |
30023054
MOD(arithmetic_expression, arithmetic_expression) |
30033055
SIZE(collection_valued_path_expression) |
3004-
INDEX(identification_variable)
3056+
INDEX(identification_variable) |
3057+
extract_datetime_field
30053058
functions_returning_datetime ::=
30063059
CURRENT_DATE |
30073060
CURRENT_TIME |
3008-
CURRENT_TIMESTAMP
3061+
CURRENT_TIMESTAMP |
3062+
extract_datetime_part
30093063
functions_returning_strings ::=
30103064
CONCAT(string_expression, string_expression{, string_expression}*) |
30113065
SUBSTRING(string_expression, arithmetic_expression[, arithmetic_expression]) |
@@ -3014,6 +3068,12 @@ functions_returning_strings ::=
30143068
UPPER(string_expression)
30153069
trim_specification ::= LEADING | TRAILING | BOTH
30163070
function_invocation ::= FUNCTION(function_name{, function_arg}*)
3071+
extract_datetime_field :=
3072+
EXTRACT(datetime_field FROM datetime_expression)
3073+
datetime_field := identification_variable
3074+
extract_datetime_part :=
3075+
EXTRACT(datetime_part FROM datetime_expression)
3076+
datetime_part := identification_variable
30173077
function_arg ::=
30183078
literal |
30193079
state_valued_path_expression |

0 commit comments

Comments
 (0)