Chapter 37 Class keyword – SqlTableName

Specifies the name of the SQL table to which this class is projected. Only applicable to persistent classes.

usage

To override the default name of the SQL table on which this class is projected, use the following syntax:

Class MyApp.Person Extends %Persistent [ SqlTableName = DBTable ]  { //class members }
Copy the code

Where DBTable is a valid SQL identifier.

Break down

This keyword specifies the name of the SQL table to which this class is projected. By default, the SQL table name is the same as the class name.

In general, you can use this keyword when the class name is an SQL reserved word (not uncommon) or you want the SQL table to contain characters not supported by the class name (such as the “_” character).

Impact on subclasses

This keyword is not inherited.

The default

If this keyword is omitted, the class name is used as the SQL table name.

Chapter 38 Class Keywords – StorageStrategy

Specifies which storage definition controls the persistence of this class. Applies only to persistent and serial classes.

usage

To specify the storage definition used by the class, use the following syntax:

Class MyApp.MyClass Extends %Persistent [ StorageStrategy = MyStorage ] 
{ //class members }
Copy the code

Where MyStorage is the name of the storage definition in this class.

Break down

This keyword specifies which storage definition is used to define the storage structure used by this class.

Typically, you don’t worry about this keyword or storage structure; The class compiler automatically defines a storage structure named “Default” and maintains it (adding new fields as needed). You can create multiple storage definitions for a class. In this case, the keyword is used to specify which storage definition the class compiler should use.

Impact on subclasses

This keyword is inherited from the main superclass. Subclasses can override the value of a keyword.

The default

If this keyword is omitted, the persistence of this class is defined by the default storage definition named default.

Chapter 39 Class keyword – System

Affects the compile order of this class

usage

To influence the order in which classes are compiled, use the following syntax:

Class MyApp.Person Extends %Persistent [ System = n ]  
{ //class members }
Copy the code

Where n is an integer between 0 and 4, and classes with lower positives are compiled before classes with higher positives. Finally compile the class with a value of 0(zero).

Break down

This keyword establishes groups of classes, each associated with a different value and priority, for which the full class compilation process is performed before moving to the next priority. From the highest priority to the lowest priority, the levels are as follows:

  • 1
  • 2
  • 3
  • 4
  • 0(the default)

Class compilation takes two steps:

  • Parse global variables.
  • Compile routines.

All classes with the same System keyword value resolve their global variables before the routine is compiled. For classes of different levels, the higher-priority class parses global variables and compiles routines before the lower-priority class parses global variables.

The CompileAfter and DependsOn keywords work in classes with common system values to determine the order of global parsing. Once all classes with common System values have resolved their global variables, all classes are compiled routinely.

Therefore, if class B needs to run A method of class A in A method generator of class B (that is, during compilation of B), then A must have higher priority than B. This means that the value of the System keyword of A must be A non-zero integer less than the value of B. To obtain this behavior, CompileAfter or DependsOn does not work.

Impact on subclasses

This keyword is not inherited.

The default

The default value is 0(zero).

Chapter 40 Class Keyword – ViewQuery

Specify an SQL query of this class. Applies only to view definition classes.

usage

To specify SQL queries for this class, use the following syntax:

ViewQuery = { statement }

Copy the code

The Where statement is an SQL SELECT statement enclosed in braces.

Break down

When defining an SQL VIEW (using the DDL CREATE VIEW statement or using the admin portal), the system automatically creates a class definition to hold the VIEW definition. For this class definition, the class type is view, and the view query is equal to the SQL statement on which the view is based.

The mechanism is internal; You don’t want users to create view classes or modify the ViewQuery keyword. Instead, use a regular mechanism (DDL or administrative portal) to manage views.

All non-view classes ignore this keyword.

The default

The default value is an empty string.

To add the keyword ClassType = view

Class YX.PersonView [ ClassType = view, ViewQuery = {Select * from sample.person} ]
{

Storage Default
{
<Data name="PersonViewDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
</Data>
<DataLocation>^YX.PersonViewD</DataLocation>
<DefaultData>PersonViewDefaultData</DefaultData>
<IdLocation>^YX.PersonViewD</IdLocation>
<IndexLocation>^YX.PersonViewI</IndexLocation>
<StreamLocation>^YX.PersonViewS</StreamLocation>
<Type>%Library.CacheStorage</Type>
}

}

Copy the code
SELECT * FROM YX.PersonView
Copy the code