QL HB: Add bindingset example

This commit is contained in:
Shati Patel
2020-01-02 13:06:17 +00:00
parent 7e84453ec9
commit b68f9f7e00

View File

@@ -271,9 +271,20 @@ Multiple binding sets specified this way are independent of each other. The abov
- If ``y`` is bound, then ``x`` and ``y`` are bound.
That is, ``bindingset[x] bindingset[y]``, which states that at least one of ``x`` or ``y`` must
be bound, is different from ``bindingset[x,y]``, which states that both ``x`` and ``y`` must be
be bound, is different from ``bindingset[x, y]``, which states that both ``x`` and ``y`` must be
bound.
The latter can be useful when you want to declare a :ref:`predicate with result <predicates-with-result>` that takes multiple input arguments::
bindingset[a, b]
int getSum(int a, int b) {
result = a + b
}
You can then use this in a :ref:`select clause <select-clauses>`, for example::
select getSum(3, 5)
.. _database-predicates:
Database predicates
@@ -283,7 +294,7 @@ Each database that you query contains tables expressing relations between values
("database predicates") are treated in the same way as other predicates in QL.
For example, if a database contains a table for persons, you can write
``persons(x, firstName, _, age)`` to constrain ``x``, ``firstName`` and ``age`` to be the
``persons(x, firstName, _, age)`` to constrain ``x``, ``firstName``, and ``age`` to be the
first, second, and fourth columns of rows in that table.
The only difference is that you can't define database predicates in QL. They are defined by the