Question
Freddy Baier · Jan 11

How to access different columns with the same name in COS?

I have this code:

SELECT id,room,client->name,functionary->name FROM rooms ORDER BY id

What i do to access the "client" name?

set rs = $SYSTEM.SQL.Execute("SELECT id,room,client->name,functionary->name FROM rooms ORDER BY id")

zw rs.%Get("name")
"return functionary name"
Product version: Caché 2018.1
$ZV: Cache for Windows (x86-64) 2018.1.5 (Build 659U) Mon Mar 22 2021 07:03:57 EDT
0
0 128
Discussion (2)2
Log in or sign up to continue

You can use 'client->name as clientname' and .%Get("clientname") or use .%GetData(columnnumber)

HI @Freddy Baier 

You can change your query, given alias to the columns:

SELECT id,room,client->name as ClientName,functionary->name as FunctionaryName FROM rooms ORDER BY id

Then in COS you access the columns by name:

Write rs.%Get("ClientName")
Write rs.%Get("FunctionaryName")