Get - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


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

Calling Sequence

Get(connection, [keys])

connection[keys]

MaybeGet(connection, [keys], default)

Set(connection, [keys], values)

connection[keys] := values

Parameters

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

Description

• 

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.

Thread Safety

• 

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.

Examples

withPersistentTable

Close,Count,Get,GetAll,GetKeys,Has,MaybeGet,Open,RawCommand,Set

(1)

connectionOpen:memory:,style=k1::anything,k2::integer,v::anything,primarykey=2

connection<< 3-column persistent table at :memory: >>

(2)

We can add rows with the Set command or using indexing.

Setconnection&comma;x&comma;3&comma;y2

connectionz,5y3

connectionz,5y3

(3)

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.

Getconnection&comma;x&comma;3

y2

(4)

connectionz,5

y3

(5)

MaybeGetconnection&comma;z&comma;5&comma;1

y3

(6)

Getconnection&comma;a&comma;4

Error, (in PersistentTable:-Get) bad index into PersistentTable

connectiona,4

Error, bad index into PersistentTable

MaybeGetconnection&comma;a&comma;4&comma;1

1

(7)

Closeconnection

Compatibility

• 

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

PersistentTable[Open]