Tutorials & ManualsSQL YogaSQL Yoga Table ObjectsHow Do I Add Custom Properties To Tables?

How Do I Add Custom Properties To Tables?

Once you have created a Table object you can define your own properties for the table. For example, if a table has a FirstName and LastName field you might define a custom property called Name that combined those two fields in order to return the full name.

Table properties that you define can be accessed when working with SQL Record objects as a SQL Record object is an instance of a record in a table.

Defining A New Table Property

Table object properties are defined in the button script assigned to the table objects behavior property of the Database object. You define a property for a Table object by creating a function with the following naming convention:


The function will be passed a SQL Record object array as the 1st parameter.

For example, to create add a name property to a people table you would add the following function to the behavior script:

function tableobj.get.people.name pRecordA
  return pRecordA["firstname"] && pRecordA["lastname"]
end tableobj.get.people.name 

Accessing a Table Object Property

You can access a Table object property when you are working with SQL Record objects by calling the sqlrecord_get function.

The following example retrieves a person from the database and then accesses the name property of the resulting SQL Record object. When accessing the property the tableobj.get.people.name function is called.

sqlrecord_find "people", 12, thePersonA
put sqlrecord_get(thePersonA, "name") into theFullName


Properties With Spaces

You can define properties that have spaces. Before calling the tableobj.get function all spaces are removed from the property name.

For example, if you tried to access the property short bio property like this:

put sqlrecord_get(thePersonA, "short bio") into theBio

then the following function would need to be defined in the behavior script:

function tableobj.get.people.shortbio pRecordA
end tableobj.get.people.shortbio 


Add your comment

E-Mail me when someone replies to this comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.