GetAll - Maple Help

PersistentTable

 GetAll
 retrieve rows from a PersistentTable connection
 GetKeys
 retrieve partial rows from a PersistentTable connection
 Count
 count rows in a PersistentTable connection

 Calling Sequence GetAll(connection, cond1, cond2, ...) GetKeys(connection, cond1, cond2, ...) Count(connection, cond1, cond2, ...)

Parameters

 connection - PersistentTable object created with the Open command cond1, cond2, ... - expression sequence of conditions involving the column names of connection

Description

 • The GetAll command retrieves all rows from a PersistentTable object that satisfy all of the specified conditions. The result is a set of lists, one for each row. Each such list contains all values for one row.
 • The GetKeys command retrieves all rows from a PersistentTable object that satisfy all of the specified conditions. The result is a set of lists, one for each row. Each such list contains the primary key values for one row. This can be considerably faster than the GetAll command if there are many columns outside the primary key and many rows in the result.
 • The Count command counts all rows from a PersistentTable object that satisfy all of the specified conditions. The returned value is the number of such rows.
 • Each condition must have one of the following forms:
 • expr1 = expr2,  expr1 <> expr2, expr1 < expr2, expr1 > expr2, expr1 <= expr2, expr1 >= expr2
 where expr1 and expr2 are polynomial expressions in the column names of connection of types integer or float. These conditions are evaluated in the SQLite database engine, so Maple's standard rules for precision in floating-point arithmetic are not followed.
 • c = expr, c <> expr
 where c is a column name of connection of type anything or boolean. Boolean columns can only be compared to the constants true and false.
 • If you expect a particular query to occur frequently, it can be very beneficial to add a suitable index. See the Open command for how to do that.

 • Persistent tables are in general thread safe as of Maple 2021; see the Thread Safety section of the PersistentTable overview page for more details and caveats.

Examples

 > $\mathrm{with}\left(\mathrm{PersistentTable}\right)$
 $\left[{\mathrm{Close}}{,}{\mathrm{Count}}{,}{\mathrm{Get}}{,}{\mathrm{GetAll}}{,}{\mathrm{GetKeys}}{,}{\mathrm{Has}}{,}{\mathrm{MaybeGet}}{,}{\mathrm{Open}}{,}{\mathrm{RawCommand}}{,}{\mathrm{Set}}\right]$ (1)
 > $\mathrm{connection}≔\mathrm{Open}\left(":memory:",\mathrm{style}=\left[\mathrm{k1}::\mathrm{anything},\mathrm{k2}::\mathrm{integer},\mathrm{v1}::\mathrm{anything},\mathrm{v2}::\mathrm{integer},\mathrm{primarykey}=2\right]\right)$
 ${\mathrm{connection}}{≔}{\mathrm{<< 4-column persistent table at :memory: >>}}$ (2)
 > $\mathrm{connection}\left[x,3\right]≔{y}^{2},4$
 ${{\mathrm{connection}}}_{{x}{,}{3}}{≔}{{y}}^{{2}}{,}{4}$ (3)
 > $\mathrm{connection}\left[z,5\right]≔{y}^{3},5$
 ${{\mathrm{connection}}}_{{z}{,}{5}}{≔}{{y}}^{{3}}{,}{5}$ (4)
 > $\mathrm{connection}\left[a,4\right]≔1,6$
 ${{\mathrm{connection}}}_{{a}{,}{4}}{≔}{1}{,}{6}$ (5)
 > $\mathrm{connection}\left[b,5\right]≔{y}^{6},7$
 ${{\mathrm{connection}}}_{{b}{,}{5}}{≔}{{y}}^{{6}}{,}{7}$ (6)

If we omit all conditions, then all rows of the table are part of the result.

 > $\mathrm{GetAll}\left(\mathrm{connection}\right)$
 $\left\{\left[{a}{,}{4}{,}{1}{,}{6}\right]{,}\left[{b}{,}{5}{,}{{y}}^{{6}}{,}{7}\right]{,}\left[{x}{,}{3}{,}{{y}}^{{2}}{,}{4}\right]{,}\left[{z}{,}{5}{,}{{y}}^{{3}}{,}{5}\right]\right\}$ (7)
 > $\mathrm{GetKeys}\left(\mathrm{connection}\right)$
 $\left\{\left[{a}{,}{4}\right]{,}\left[{b}{,}{5}\right]{,}\left[{x}{,}{3}\right]{,}\left[{z}{,}{5}\right]\right\}$ (8)
 > $\mathrm{Count}\left(\mathrm{connection}\right)$
 ${4}$ (9)

Here we demonstrate a simple equality condition.

 > $\mathrm{GetAll}\left(\mathrm{connection},\mathrm{v1}={y}^{3}\right)$
 $\left\{\left[{z}{,}{5}{,}{{y}}^{{3}}{,}{5}\right]\right\}$ (10)
 > $\mathrm{GetKeys}\left(\mathrm{connection},\mathrm{v1}={y}^{3}\right)$
 $\left\{\left[{z}{,}{5}\right]\right\}$ (11)
 > $\mathrm{Count}\left(\mathrm{connection},\mathrm{v1}={y}^{3}\right)$
 ${1}$ (12)

More complicated conditions.

 > $\mathrm{GetAll}\left(\mathrm{connection},100<\mathrm{k2}{\mathrm{v2}}^{2},\mathrm{k1}\ne a\right)$
 $\left\{\left[{b}{,}{5}{,}{{y}}^{{6}}{,}{7}\right]{,}\left[{z}{,}{5}{,}{{y}}^{{3}}{,}{5}\right]\right\}$ (13)
 > $\mathrm{GetKeys}\left(\mathrm{connection},100<\mathrm{k2}{\mathrm{v2}}^{2},\mathrm{k1}\ne a\right)$
 $\left\{\left[{b}{,}{5}\right]{,}\left[{z}{,}{5}\right]\right\}$ (14)
 > $\mathrm{Count}\left(\mathrm{connection},100<\mathrm{k2}{\mathrm{v2}}^{2},\mathrm{k1}\ne a\right)$
 ${2}$ (15)
 > $\mathrm{Close}\left(\mathrm{connection}\right)$

Compatibility

 • The PersistentTable[GetAll], PersistentTable[GetKeys] and PersistentTable[Count] commands were introduced in Maple 2021.