Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 3 of 3 total |
How do I know if a STORE exists? |
Mon, Jun 24 2013 11:14 PM | Permanent Link |
Jeff Cook Aspect Systems Ltd | Just started to dabble with ElevateDB - just converted a Delphi7/DBISAM3
application to DelphiXE/ElevateDB2. So far I've had success with a simple app, but struck a problem with BackUps and STOREs. The follwong works OK the first time:- ----------------------------------------- frmMain.EDBSession.Execute('CREATE STORE "BackUps" AS LOCAL PATH ' + frmMain.EDBEngine.QuotedSQLStr(edtLocation.Text) + ' DESCRIPTION ''ACES Database Backups'''); frmMain.EDBSession.Execute('BACKUP DATABASE "ACES" ' + 'AS "ACES-Backup-' + frmMain.EDBEngine.DateToSQLStr(Date) + '" ' + 'TO STORE "BackUps" ' + 'INCLUDE CATALOG'); ------------------------------------------ .... but subsequent runs fails on the CREATE STORE because it already exists. I know how to "SELECT * FROM Information.Tables WHERE ..." to find out if a table exists, but I can't see how to do the same with a Store. TIA Jeff -- Jeff Cook Aspect Systems Ltd www.aspect.co.nz |
Tue, Jun 25 2013 3:13 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Jeff
>I know how to "SELECT * FROM Information.Tables WHERE ..." to find out if a >table exists, but I can't see how to do the same with a Store. That's cos the information is in Configuration select * from configuration.stores But I don't bother if buLocation <> '' then begin ForceDirectories(buLocation); try dm.TfRSession.Execute('DROP STORE "buTfR" KEEP CONTENTS'); except end; dm.TfRSession.Execute('CREATE STORE "buTfR" AS LOCAL PATH ' + QuotedStr(buLocation)); Roy Lambert [Team Elevate] |
Tue, Jun 25 2013 5:24 PM | Permanent Link |
Jeff Cook Aspect Systems Ltd | Thanks Roy
>>I know how to "SELECT * FROM Information.Tables WHERE ..." to find out if >>a >>table exists, but I can't see how to do the same with a Store. > > That's cos the information is in Configuration > > select * from configuration.stores > > But I don't bother > > if buLocation <> '' then begin > ForceDirectories(buLocation); > try > dm.TfRSession.Execute('DROP STORE "buTfR" KEEP CONTENTS'); > except > end; > dm.TfRSession.Execute('CREATE STORE "buTfR" AS LOCAL PATH ' + > QuotedStr(buLocation)); > Ah! Configuration, not Information. I'll have read more in the Help! Not so keen on the "try except end;" to swallow the error - I could have done it like this:- ============ try .... Session.Execute('CREATE STORE ...'); except end; Session.Execute('BACKUP DATABASE ...'); ============ .... but baulked at swallowing the error. So I have adapted one of the routines you posted here:- ============= function TCommon.IsStoreThere(const SessionName, DatabaseName, StoreName: string): Boolean; var Checker: TEDBQuery; begin Checker := TEDBQuery.Create(nil); try Checker.SessionName := SessionName; Checker.DatabaseName := DatabaseName; Checker.SQL.Text := 'SELECT * FROM Configuration.Stores WHERE Name = ' + QuotedStr(StoreName); Checker.ExecSQL; Result := Checker.RecordCount > 0; finally Checker.Close; Checker.Free; end; end; ================ Thanks again Jeff |
This web page was last updated on Monday, April 29, 2024 at 05:23 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |