Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 3 of 3 total |
Struggling with testing if a table exists |
Mon, Dec 21 2020 12:08 PM | Permanent Link |
bpolky | I am a new user of Elevate DB, trying to convert my existing system from another database manager. I want to create a separate table in a database for each user (same fields). If that user is new, it must create a table for them. That means testing to see if a table already exists. I am using the code from this forum for testing the table exists.
My test code looks like.... Var SQLString : String; TableName : String; Const RetStr : string = ''#13#10''; begin TableName := 'Test1'; TabTest.TableName := TableName; SQLString := 'CREATE TABLE "' + TableName + '"' + RetStr; SQLString := SQLString + '(' + RetStr; SQLString := SQLString + '"Studio" INT' + RetStr; SQLString := SQLString + ')'; EDB.Execute(SQLString); ShowMessage('Check Manager for table'); EDB.Execute('SELECT Version FROM Information.Tables WHERE Name = "Test1"'); end; At the ShowMessage point I can see that the table 'Test1' exists in the database. But when I test for it, I get the error 'The column Test1 does not exist in the temporary table Tables". Am I testing for the wrong thing? Can someone explain where my error is? |
Mon, Dec 21 2020 1:00 PM | Permanent Link |
Raul Team Elevate | On 12/21/2020 12:08 PM, bpolky wrote:
> EDB.Execute('SELECT Version FROM Information.Tables WHERE Name = "Test1"'); > end; > > At the ShowMessage point I can see that the table 'Test1' exists in the database. But when I test for it, I get the error 'The column Test1 does not exist in the temporary table Tables". > Am I testing for the wrong thing? > Can someone explain where my error is? > The Test1 is this case is a string literal (field value and not a db object) so you need to use single quotes : SELECT Version FROM Information.Tables WHERE Name = 'Test1' Raul |
Mon, Dec 21 2020 1:12 PM | Permanent Link |
bpolky | Raul wrote:
The Test1 is this case is a string literal (field value and not a db object) so you need to use single quotes : SELECT Version FROM Information.Tables WHERE Name = 'Test1' Raul Thanks. I thought I had tried everything, but missed the obvious stuff. |
This web page was last updated on Friday, April 19, 2024 at 07:09 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |