Subscribe to this thread
Home - General / All posts - RENAME TABLE does not parse stored values
tjhb

8,657 post(s)
#13-Apr-19 03:32

There might be a good reason for this not being possible.

In RENAME TABLE [old] [new], neither [old] nor [new] can be replaced by a stored VALUE (whether NVARCHAR or TABLE) nor e.g. by PragmaValue('creatednamequoted').

It would be convenient if it were possible, or if there were some other way to synthesize table names (I really mean table references) from strings.

adamw


8,447 post(s)
online
#19-Apr-19 14:35

We don't currently allow composing component / schema item names from expressions. Mostly not because we cannot do so - we can, our SQL statements are dynamic enough for component / field / index / constraint names to be determined at runtime - but rather because the syntax seems a little too permitting, maybe we should restrict it in some way.

We are fine with just:

--SQL9

RENAME TABLE @a @b;

...but less fine with:

--SQL9

RENAME TABLE 'name' 'my' + @value + currentDate() + askUserForPostfix('hi');

...because it is very unclear from the above that the old name is 'name' and the rest is the new name, the space that separates the old name from the new name just gets lost in the noise.

Maybe we should have a construct like RENAME TABLE $(...), probably with something other than $, which would indicate that in this particular place we are composing an identifier from an expression.

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