Records versus Property Lists

It is important to understand that a record is different from an ordinary property list.

A record is a property list that has a connection to a row in a database table. Changing the value of a property in a record directly updates the corresponding value in the database. However, a record may also be assigned other properties that do not correspond to columns in the database table. If a property is assigned or changed that is not a column in the database, that value is only changed in the record object, and the database is not affected.

When a record is assigned to another variable, all of its properties are copied, but the copy does not keep a connection to the database. This is by design, to avoid unexpected consequences. The database connection can be retained in the copy by using the as record operator to indicate that the new copy should also be a record.

Note: The same effect could also be achieved for a single record by making a reference to the original record, but this technique will not work for a list of records. Using the as record operator is the preferred approach.

set member to the record of memberTable where memberNumber is desiredMemNum

put member into newMember-- newMember has NO connection to database

put member as record into member2-- member2 HAS a connection to database

The is a record operator can be used to determine if a value is a record (is connected to the database).

if member3 is a record then

 

This topic was last updated on October 11, 2019, at 11:18:54 AM.

Eggplant icon Eggplantsoftware.com | Documentation Home | User Forums | Support | Copyright © 2019 Eggplant