Variables and Table Names
Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller
-
- Posts: 77
- Joined: Thu May 21, 2015 2:41 am
Variables and Table Names
I'm having fits trying to create a table using a variable for its name. I have several truncated layers of storage in my app and need the program to generate unique names for each table, but I'm struggling to get it to work. I can get them to run if I define the table names, but if I set the same names in variables and use the variable to call the unique name for the new table in the database it doesn't execute the SQL.
"CREATE TABLE IF NOT EXISTS "&variableTbName&" (column1, column2,..etc);" into tSQL
I've keyed the exact same thing with the actual name I want to use and it works fine. I can't seem to figure out why it isn't working with the variable...help...
"CREATE TABLE IF NOT EXISTS "&variableTbName&" (column1, column2,..etc);" into tSQL
I've keyed the exact same thing with the actual name I want to use and it works fine. I can't seem to figure out why it isn't working with the variable...help...
-
- Posts: 77
- Joined: Thu May 21, 2015 2:41 am
Re: Variables and Table Names
...of course as soon as I post this I figure out the problem. Please disregard.
Re: Variables and Table Names
Glad we could help! 

Re: Variables and Table Names
And your solution is?Not a lot of thought wrote:...of course as soon as I post this I figure out the problem. Please disregard.
Re: Variables and Table Names
Try this:
Note that I added the ' char before and after the " char
Code: Select all
"CREATE TABLE IF NOT EXISTS '" & variableTbName & "' (column1 TEXT, column2 NUMBER,..etc);" into tSQL
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Variables and Table Names
OIC, thanks.MaxV wrote:Try this:
Note that I added the ' char before and after the " charCode: Select all
"CREATE TABLE IF NOT EXISTS '" & variableTbName & "' (column1 TEXT, column2 NUMBER,..etc);" into tSQL