Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 10 of 14 total |
Exists method |
Fri, Apr 18 2008 3:45 PM | Permanent Link |
"Jose Eduardo Helminsky" | I have my own Table component that is inherited from TEDBTable
The code below could be an exist method ? function THProTable.Exists: Boolean; begin Result := Session.Execute('select name from information.tables where name='+QuotedStr(Tablename)) > 0; end; Eduardo |
Fri, Apr 18 2008 7:35 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Eduardo,
<< The code below could be an exist method ? >> Actually, this is what you need: function THProTable.Exists: Boolean; begin CheckActive; Result := Database.Execute('select name from information.tables where name='+QuotedStr(Tablename)) > 0; end; You want to execute any such query from the context of the database defined for the table, and you need the database open to do so. -- Tim Young Elevate Software www.elevatesoft.com |
Tue, Apr 22 2008 6:18 AM | Permanent Link |
"Jose Eduardo Helminsky" | Tim
<< Actually, this is what you need: function THProTable.Exists: Boolean; begin CheckActive; Result := Database.Execute('select name from information.tables where name='+QuotedStr(Tablename)) > 0; end; >> If I am understanding it correctly the Database is the EDBDatabase component because there is no Database property at TEBTable level. In my case, the Database is not available in this unit then since I am only using one database per application, then I could use Session.Databases[0].Execute ? Eduardo |
Tue, Apr 22 2008 11:56 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Eduardo,
<< If I am understanding it correctly the Database is the EDBDatabase component because there is no Database property at TEBTable level. >> No, there's a Database property at the TEDBTable level. It's set to a temporary TEDBDatabase component if you don't explicitly have one assigned via the DatabaseName property. << In my case, the Database is not available in this unit then since I am only using one database per application, then I could use Session.Databases[0].Execute ? >> Are you saying that the TEDBTable doesn't have its DatabaseName property assigned yet in that unit ? If so, then you'll have to figure out a way to assign it a value prior to calling this method. The TEDBTable must be open for this method to work. -- Tim Young Elevate Software www.elevatesoft.com |
Wed, Apr 23 2008 6:02 AM | Permanent Link |
"Jose Eduardo Helminsky" | Tim
<< No, there's a Database property at the TEDBTable level. It's set to a temporary TEDBDatabase component if you don't explicitly have one assigned via the DatabaseName property. >> Ok, got it. << Are you saying that the TEDBTable doesn't have its DatabaseName property assigned yet in that unit ? If so, then you'll have to figure out a way to assign it a value prior to calling this method. The TEDBTable must be open for this method to work. >> No, at this time DatabaseName property should by assigned but why TEDBTable must be opened ? I am trying to know if it exists. Eduardo |
Wed, Apr 23 2008 11:45 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Eduardo,
<< No, at this time DatabaseName property should by assigned but why TEDBTable must be opened ? I am trying to know if it exists. >> Crap, I forgot about that. What you need instead is this: function THProTable.Exists: Boolean; begin SetDatabaseFlag(dbfTable,True); try Result := Database.Execute('select name from information.tables where name='+QuotedStr(Tablename)) > 0; finally SetDatabaseFlag(dbfTable,False); end; end; -- Tim Young Elevate Software www.elevatesoft.com |
Wed, Apr 23 2008 1:19 PM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Tim
Can you explain that function - it looks useful but what is SetDatabaseFlag(dbfTable,True);? Roy Lambert |
Wed, Apr 23 2008 3:20 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Roy,
<< Can you explain that function - it looks useful but what is SetDatabaseFlag(dbfTable,True);? >> It's an internal function for opening up the referenced database for temporary purposes. -- Tim Young Elevate Software www.elevatesoft.com |
Wed, Apr 23 2008 4:11 PM | Permanent Link |
"Jose Eduardo Helminsky" | Tim
The big question: Why this function is not available as a method of TEBTable ? I know ElevateDB is going to SQL based operations in a lot of areas but if you don´t see any problems with the above code, then I think a lot of users will be happy with this. Eduardo |
Wed, Apr 23 2008 4:36 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Eduardo,
<< Why this function is not available as a method of TEBTable ? I know ElevateDB is going to SQL based operations in a lot of areas but if you don´t see any problems with the above code, then I think a lot of users will be happy with this. >> The issue is that it starts us back down the slippery slope of wanting meta-data methods in the TEDBTable component. Today it's Exists, tomorrow it's "CreateTable", and we simply cannot do those methods anymore due to the complex nature of the table structures now with respect to constraints, triggers, etc. -- Tim Young Elevate Software www.elevatesoft.com |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Monday, July 1, 2024 at 03:00 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |