Subscribe to this thread
Home - General / All posts - Table variable referencing same tables
sga8 post(s)
#21-Oct-21 08:15

In M9, I have 2 query scripts

[Q1]

-- $manifold$

SELECT * FROM [mfd_meta];

[Q2]

-- $manifold$

--1st query

SELECT * FROM [mfd_meta], [Q1]; -- this works

VALUE @table_name TABLE = [mfd_meta];

--2nd query

SELECT * FROM @table_name; -- this works

--3rd query

SELECT * FROM @table_name, [Q1]; -- this fails: invalid object reference

--4th query

SELECT * FROM @table_name, (EXECUTE [Q1]); -- this works as a workaround to the previous query

I'm wondering why the 4th query fails, whereas the 1st and 4th work. My guess is that it has something to do with locks or something similar. I'd like to better understand how the assignment of a table to a variable works (more precisely table resulting from a query): does it store the data in the variable or is it just an alias?

Many thanks in advance

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.