Is there a way that I can define a primary to havfe a computed value? I am trying to map a global with a structure similar to
where SYSTEM=$piece($system,",",2), and I don't want to define SYSTEM as a literal string in the table. I also don't want to need supply the value for SYSTEM for sql queries or updates. Is there a way the SYSTEM key can be computed? Thanks.
No, you can use a computed that way. A computed is equivalent to an RDB function. It is not a physical column and hence cannot be set, only read.
You could try using a before insert trigger to define SYSTEM prior to the insert. I don't see how that would help for updates, however, since you need that key to load the record to do the update on it, but you could try playing around with a before update trigger. And, I can't think of anything that will help you for queries unless there is some other column that has that key's same uniqueness.
More information on what this global represents and how you want to use it might help in coming up with a better answer.
I can work around this problem fairly easily. I was mainly interested in whether it was possible to define the key via code. It looked as if the Primary Keys Access Routine table property might provide a way to do this. Is this facility primarily intended for record level access control? Or is that what the Data Item Protection Filename property is for?
The Primary Keys Access Routine (DBTBL1.UDACC) will be obsoleted in a future release. It's purpose was to provide a user-defined screen to prompt for access keys versus a standard DATA-QWIK generated screen. This allowed for edit checking, defaulting, etc. to gather the keys for maintenance screens back when screens were heavily used.
The Data Item Protection Filename is used when Data Item Protection is applied to a table. This provides a name that is used to construct the Data Item Protection code. DIP provides a means to restrict access to rows and/or columns in tables, similar to access rights.