Skip to content

Commit

Permalink
Release v0.2.2
Browse files Browse the repository at this point in the history
Add row values.
  • Loading branch information
mithrandie committed Jun 27, 2017
2 parents b58e623 + dd76d40 commit a268dbb
Show file tree
Hide file tree
Showing 26 changed files with 6,062 additions and 3,895 deletions.
1 change: 1 addition & 0 deletions docs/_includes/side_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<li><a href="{{ '/reference/create-table-query.html' | relative_url }}">Create Table Query</a></li>
<li><a href="{{ '/reference/alter-table-query.html' | relative_url }}">Alter Table Query</a></li>
<li><a href="{{ '/reference/variable.html' | relative_url }}">Variable</a></li>
<li><a href="{{ '/reference/row-value.html' | relative_url }}">Row Value</a></li>
<li><a href="{{ '/reference/cursor.html' | relative_url }}">Cursor</a></li>
<li><a href="{{ '/reference/control-flow.html' | relative_url }}">Control Flow</a></li>
<li><a href="{{ '/reference/transaction.html' | relative_url }}">Transaction Management</a></li>
Expand Down
64 changes: 49 additions & 15 deletions docs/_posts/2006-01-02-comparison-operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,32 @@ A comparison operator returns a ternary value.
| <>, !\= | Not equal |

```sql
value operator value
relational_operation
: value operator value
| row_value operator row_value
```

_value_
: [value]({{ '/resference/value.html' | relative_url }})

_row_value_
: [Row Value]({{ '/resference/row-value.html' | relative_url }})

At first, a relational operator attempt to convert both of operands to float values, and if both convertions are successful then compare them.
If conversions failed, next a relational operater attempt to convert to datetime, and next to boolean, at last to string.

If either of operands is null or all conversion failed, return UNKNOWN.

In case of _row_values_ comparison, both of _row_values_ must be tha same lengths.
Values at the same indices are compared, and the result is decided by [AND]({{ '/reference/logic-operators.html#and' | relative_url }}) condition of each comparisons

## IS
{: #is}

```sql
value IS [NOT] ternary
value IS [NOT] NULL
is_operation
: value IS [NOT] ternary
| value IS [NOT] NULL
```

_value_
Expand All @@ -63,7 +72,9 @@ Evaluate the ternary value of _value_ and check if the ternary value is equal to
{: #between}

```sql
value [NOT] BETWEEN low AND high
between_operation
: value [NOT] BETWEEN low AND high
| row_value [NOT] BETWEEN row_value_low AND row_value_high
```

_value_
Expand All @@ -75,6 +86,15 @@ _low_
_high_
: [value]({{ '/reference/value.html' | relative_url }})

_row_value_
: [Row Value]({{ '/resference/row-value.html' | relative_url }})

_row_value_low_
: [Row Value]({{ '/resference/row-value.html' | relative_url }})

_row_value_high_
: [Row Value]({{ '/resference/row-value.html' | relative_url }})

Check a _value_ is greater than or equal to _low_ and less than or equal to _high_.

The BETWEEN operation is equivalent to followings.
Expand All @@ -87,22 +107,24 @@ NOT (low <= value AND value <= high)
{: #in}

```sql
value [NOT] IN (value [, value ...])
value [NOT] IN (select_query)
in_operation
: value [NOT] IN row_value
| row_value [NOT] IN (row_value [, row_value ...])
| row_value [NOT] IN (select_query)
```

_value_
: [value]({{ '/reference/value.html' | relative_url }})

_row_value_
: [Row Value]({{ '/resference/row-value.html' | relative_url }})

_select_query_
: [Select Query]({{ '/reference/select-query.html' | relative_url }})

Check if a _value_ is in within a set of _values_ or a result set of _select_query_.
Check if a _value_ or _row_value_ is in within a set of _values_ or a result set of _select_query_.

The IN operation with subquery is equivalent to following ANY operation.
```sql
value = ANY (select_query)
```
A IN operation is equivalent to a ANY operation that operator is specified as "=".

## LIKE
{: #like}
Expand Down Expand Up @@ -132,19 +154,25 @@ _
{: #any}

```sql
value relational_operator ANY (select_query)
any_operation
: value relational_operator ANY row_value
| row_value relational_operator ANY (row_value [, row_value ...])
| row_value relational_operator ANY (select_query)
```

_value_
: [value]({{ '/reference/value.html' | relative_url }})

_row_value_
: [Row Value]({{ '/resference/row-value.html' | relative_url }})

_relational_operator_
: [relational operator](#relational_operators)

_select_query_
: [Select Query]({{ '/reference/select-query.html' | relative_url }})

Compare a _value_ to each values retrieved by _select_query_.
Compare a _value_ or _row_value_ to each listed _values_ or values retrieved by _select_query_.
If any of comparison results is TRUE, return TRUE.
If there is no TRUE result and there is at least one UNKNOWN result, return UNKNOWN.
Otherwise return FALSE.
Expand All @@ -155,19 +183,25 @@ If _select_query_ returns no values, return FALSE.
{: #all}

```sql
value relational_operator ALL (select_query)
all_operation
: value relational_operator ALL row_value
| row_value relational_operator ALL (row_value [, row_value ...])
| row_value relational_operator ALL (select_query)
```

_value_
: [value]({{ '/reference/value.html' | relative_url }})

_row_value_
: [Row Value]({{ '/resference/row-value.html' | relative_url }})

_relational_operator_
: [relational operator](#relational_operators)

_select_query_
: [Select Query]({{ '/reference/select-query.html' | relative_url }})

Compare a _value_ to every values retrieved by _select_query_.
Compare a _value_ or _row_value_ to every listed _values_ or values retrieved by _select_query_.
If any of comparison results is FALSE, return FALSE.
If there is no FALSE result and there is at least one UNKNOWN result, return UNKNOWN.
Otherwise return TRUE.
Expand Down
6 changes: 3 additions & 3 deletions docs/_posts/2006-01-02-insert-query.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Insert query is used to insert records to a csv file.
```sql
INSERT INTO table_name
[(column_name [, column_name ...])]
VALUES (value [, value ...]) [, (value [, value ...]) ...]
VALUES row_value [, row_value ...]
```

_table_name_
Expand All @@ -22,8 +22,8 @@ _table_name_
_column_name_
: [identifier]({{ '/reference/statement.html#parsing' | relative_url }})

_value_
: [value]({{ '/reference/value.html' | relative_url }})
_row_value_
: [Row Value]({{ '/reference/row-value.html' | relative_url }})

## Insert From Select Query

Expand Down
28 changes: 28 additions & 0 deletions docs/_posts/2006-01-02-row-value.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
layout: default
title: Row Value - Reference Manual - csvq
category: reference
---

# Row Value

A Row Value is a ordered list of values.

```sql
row_value
: (value [, value...])
| (select_query)
```

_value_
: [value]({{ '/reference/value.html' | relative_url }})

_select_query_
: [Select Query]({{ '/reference/select-query.html' | relative_url }})

Retrieved fields of _select_query_ are used as listed values.
The result set of _select_query_ must be at most one record.


Row Values can be used in limited operation such as [Comparison Operation]({{ '/reference/comparison-operators.html' | relative_url }}) or [Insert Query]({{ '/reference/insert-query.html' | relative_url }}).
In most cases, a row value with a single value is interpreted as a value with parentheses.
23 changes: 22 additions & 1 deletion docs/_posts/2006-01-02-select-query.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ select_query
: select_entity
[order_by_clause]
[limit_clause]
[offset_clause]
select_entity
: select_clause
[from_clause]
[where_clause]
[group_by_clause]
[having_clause]
| select_entity set_operator [ALL] select_entity
| select_set_entity set_operator [ALL] select_set_entity
select_set_entity
: select_entity
| (select_query)
```

_select_clause_
Expand All @@ -44,6 +49,9 @@ _order_by_clause_
_limit_clause_
: [Limit Clause](#limit_clause)

_offset_clause_
: [Offset Clause](#offsetma_clause)

_set_operator_
: [Set Operators]({{ '/reference/set-operators.html' | relative_url }})

Expand Down Expand Up @@ -243,3 +251,16 @@ LIMIT number

_number_
: [integer]({{ '/reference/value.html#integer' | relative_url }})


## Offset Clause
{: #offset_clause}

The Offset clause is used to exclude the first set of records.

```sql
OFFSET number
```

_number_
: [integer]({{ '/reference/value.html#integer' | relative_url }})
6 changes: 3 additions & 3 deletions docs/_posts/2006-01-02-set-operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ select_query UNION [ALL] select_query
```

_select_query_
: [select_entity]({{ '/reference/select-query.html' | relative_url }})
: [select_set_entity]({{ '/reference/select-query.html' | relative_url }})

Return all records of both result sets.

Expand All @@ -35,7 +35,7 @@ select_query EXCEPT [ALL] select_query
```

_select_query_
: [select_entity]({{ '/reference/select-query.html' | relative_url }})
: [select_set_entity]({{ '/reference/select-query.html' | relative_url }})

Return records of a first result set that do not appear in a second result set.

Expand All @@ -47,6 +47,6 @@ select_query INTERSECT [ALL] select_query
```

_select_query_
: [select_entity]({{ '/reference/select-query.html' | relative_url }})
: [select_set_entity]({{ '/reference/select-query.html' | relative_url }})

Return only records that appear in both result sets.
2 changes: 1 addition & 1 deletion docs/_posts/2006-01-02-statement.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ IF IN INNER INSERT INTERSECT INTO IS
JOIN
LAST LEFT LIKE LIMIT
NATURAL NOT NULL
ON OPEN OR ORDER OUTER
OFFSET ON OPEN OR ORDER OUTER
PRINT
RENAME RIGHT ROLLBACK
SELECT SET SEPARATOR STDIN
Expand Down
1 change: 1 addition & 0 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ title: Reference Manual - csvq
* [Create Table Query]({{ '/reference/create-table-query.html' | relative_url }})
* [Alter Table Query]({{ '/reference/alter-table-query.html' | relative_url }})
* [Variable]({{ '/reference/variable.html' | relative_url }})
* [Row Value]({{ '/reference/row-value.html' | relative_url }})
* [Cursor]({{ '/reference/cursor.html' | relative_url }})
* [Control Flow]({{ '/reference/control-flow.html' | relative_url }})
* [Transaction Management]({{ '/reference/transaction.html' | relative_url }})
Expand Down
Loading

0 comments on commit a268dbb

Please sign in to comment.