Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Objects</strong> and SQL<br />
• All the columns in the projection of the superclass (that is, those based on all the properties<br />
in its superclass' extent)<br />
• Additional columns based on properties only in the subclass<br />
• A subset of the rows in the superclass' table that consists only of the instances of the<br />
subclass<br />
For example, the projection of a persistent class called Sample.Employee that is derived from<br />
the Sample.Person class is a table containing all the fields defined by both the<br />
Sample.Employee and Sample.Person classes. This is illustrated in the following SQL queries.<br />
First list all instances of Sample.Person and its properties:<br />
SELECT * FROM Sample.Person<br />
Now list all instances of Sample.Employee and its properties:<br />
SELECT * FROM Sample.Employee<br />
Typically, the table of a subclass has more columns and fewer rows than its parent. There<br />
are more columns in the subclass since it usually adds additional properties when it extends<br />
the parent class; there are often fewer rows since there are often fewer instances of the subclass<br />
than the parent.<br />
13.1.1 How a Class is Projected to SQL<br />
To create a class that is automatically accessible from SQL, define it based on the %Persistent.<br />
When you compile the class, the <strong>Caché</strong> Class Compiler automatically generates the runtime<br />
information needed for relational access. The class' instances are then available as the rows<br />
of a relational table.<br />
13.1.2 Naming Rules for Projected Classes<br />
<strong>Caché</strong> itself places no restrictions on class names. However, SQL tables cannot have names<br />
that are SQL Reserved Words; hence, if you create a persistent class with a name that is a<br />
reserved word, the <strong>Caché</strong> Class Compiler will generate an error message. In this case, you<br />
must either rename the class or specify a table name for the projection that differs from the<br />
class name; to do this, use the SQLTABLENAME keyword, which has the following syntax:<br />
SQLTABLENAME = TableNameForSQL;<br />
114 <strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong>