Published on InterSystems Developer Community (https://community.intersystems.com)

Home > ID vs %ID in tables

Question
Keshav Iyer · Oct 30, 2018

ID vs %ID in tables

What is the difference between %ID and ID in a database table? Both seem to reference the same column labelled ID.

For context, I am trying to create a viewer class for an existing persistent class.

Let us call the persistent class A, with SqlTableName = OldA.

The viewer class will be B with SqlTableName = A and ViewQuery = {select %ID, <other fields> from <some other class with the same fields as A>}

In A, there exists a class query: select %ID from A. However, A fails to compile, giving an error: "Field '%ID' not found in applicable tables". If the %ID is replaced with ID, the class compiles. 

#SQL #Caché

Source URL:https://community.intersystems.com/post/id-vs-id-tables