[Code sea shell TC] Use View to define dynamic Class, sea shell tc
Preface
In TC,
Persistent Class corresponds to Table.
Define a Persistent Class. updatedb generates the corresponding table.
In the development environment of TC, a corresponding username will generate a table under this username
In the formal environment, because adm, su, and key are used, the corresponding table will be generated under these three usernames.
The specific table in which the data is stored depends on where the Class definition inherits (if it inherits from admin, it is stored under the username corresponding to admin)
Then use QueryDbObject to query the Class.
You can set a Scope parameter during query.
SC _SCOPE_OF_SESSION -- query in the table corresponding to the current user (basically su)
SC _SCOPE_WHERE_NECESSARY -- query in the table corresponding to all users
In addition to the QueryDbobject method, TC also provides the QueryDbView method to Query data in the View.
This View does not need to correspond to a Persistent Class, but a View.
So, how can this development be done? What should I pay attention?
Query View
1. First, define the db view
CREATE OR REPLACE FORCE VIEW "VTEST" ASSELECT ATT AS ATT, '-' AS CreationDate , '-' AS CurDbName , '-' AS LastUpdate , '-' AS OBID , NULL AS Recycled , NULL AS SEIndexLanguageList , NULL AS ZBlob , 'VTEST' AS ClassFROM View SQL;
Here the ATT proxy needs to define an attribute
Note that, in addition to the attribute needed for processing the definition, you also need to define the attribute used by some systems.
2. Second, define a dynamic class
define dynamic class VTEST with parent PdmRoot;{ attach ATT;}
3. After definition, the View contains data. You can use QueryDbView to find data.
In the official environment,
1. If the SQL statement used to create a View is executed in all three databases, use the scope SC _SCOPE_WHERE_NECESSARY for query,
The data will be repeated (three pieces)
2. If the SQL statement used to create the View is executed only in the su db, use the scope SC _SCOPE_WHERE_NECESSARY to query, and the table cannot be found.
A good way is to create a view in the su db and use SC _SCOPE_OF_SESSION to query