PersistentTable
Get
retrieve a row from a PersistentTable connection
MaybeGet
maybe retrieve a row from a PersistentTable connection
Set
enter a row into a PersistentTable connection
Calling Sequence
Parameters
Description
Thread Safety
Examples
Compatibility
Get(connection, [keys])
connection[keys]
MaybeGet(connection, [keys], default)
Set(connection, [keys], values)
connection[keys] := values
connection
-
PersistentTable object created with the Open command
keys
expression sequence of values for the key columns
default
expression sequence of values to return if the keys are not found
values
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.
with⁡PersistentTable
Close,Count,Get,GetAll,GetKeys,Has,MaybeGet,Open,RawCommand,Set
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.
Set⁡connection,x,3,y2
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.
Get⁡connection,x,3
y2
connectionz,5
y3
MaybeGet⁡connection,z,5,1
Get⁡connection,a,4
Error, (in PersistentTable:-Get) bad index into PersistentTable
connectiona,4
Error, bad index into PersistentTable
MaybeGet⁡connection,a,4,1
1
Close⁡connection
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.
See Also
PersistentTable[Open]
Download Help Document