Question
· 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. 

Discussion (1)1
Log in or sign up to continue

Hi Keshav,

%ID is a psuedo field that will always reference the RowID, by default this is named as ID, but could also be ID1, ID2 .. IDn

More about it here...

https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GSQL_tables#GSQL_tables_idfield

Not sure about your error, would need to see your full code.

If you are not naming properties as ID, then just use ID.

Sean.