retrieve a row from a PersistentTable connection
maybe retrieve a row from a PersistentTable connection
enter a row into a PersistentTable connection
MaybeGet(connection, [keys], default)
Set(connection, [keys], values)
connection[keys] := values
PersistentTable object created with the Open command
expression sequence of values for the key columns
expression sequence of values to return if the keys are not found
expression sequence of values to use for the non-key columns
The Get command retrieves the row in the table given by the connection object that has the values in keys as its primary key, and returns the values that are not part of the primary key. If no such row exists, then it generates an error.
Indexing the connection object with keys is equivalent to calling Get.
The MaybeGet command retrieves the row in the table given by the connection object that has the values in keys as its primary key, and returns the values that are not part of the primary key. If no such row exists, then it returns default.
The Set command enters a new row into the connection object, or modifies an existing row, depending on whether a row with the given keys exists.
Assigning to a connection object indexed with keys is equivalent to calling Set.
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.
For more information on thread safety, see index/threadsafe.
connection ≔ Open⁡:memory:,style=k1::anything,k2::integer,v::anything,primarykey=2
connection≔<< 3-column persistent table at :memory: >>
We can add rows with the Set command or using indexing.
connectionz,5 ≔ y3
If we retrieve a row, we can use Get, indexing, or MaybeGet. The former two methods generate an error if the key does not exist; the latter does not.
Error, (in PersistentTable:-Get) bad index into PersistentTable
Error, bad index into PersistentTable
The PersistentTable[Get], PersistentTable[MaybeGet] and PersistentTable[Set] commands were introduced in Maple 2021.
For more information on Maple 2021 changes, see Updates in Maple 2021.
Download Help Document