Ahoy! I am using the query() command a lot to access Global Table data, and I love the $ syntax for building parameterized queries. However, it seems like I can only pass in a parameterized table via reftable(). If I try to pass in a treenode of a Global Table or a Global Variable pointing to a Global Table, I get an error. This is confusing, since I thought that reftable() was a node reference. See below for my example code querying a "sample_table".
I'd like to be able to save my table to something like a global variable to make updating it easy/centralized; I could do this with reftable() and a Global Macro for table-name, but a node reference would ideally be a faster.
This parameterized query works fine:
- query("SELECT * FROM $1 WHERE PART_NUMBER = 'E'", reftable("sample_table"));
- int rows = getquerymatchcount();
- if (rows > 0) {
- string res = getqueryvalue(1, "MATERIAL_LOC");
- pt(res);
- } else {
- pt("no matches");
- }
This query with a table node reference doesn't work.
- query("SELECT * FROM $1 WHERE PART_NUMBER = 'E'",
- node("Tools/GlobalTables/sample_table", model()));
- int rows = getquerymatchcount();
- if (rows > 0) {
- string res = getqueryvalue(1, "MATERIAL_LOC");
- pt(res);
- } else {
- pt("no matches");
- }
This surprisingly also doesn't work if I pass in a Global Variable set to reftable("sample_table").