Icon Creating and Using Stores

A store is simply a named storage area that holds files and includes user security privileges so that you can prevent any accidental destruction or viewing of sensitive files. Creating, altering, and dropping stores, and working with the files contained within them, is accomplished by using the TEDBSession Execute method to execute the CREATE STORE, ALTER STORE, DROP STORE, RENAME STORE,SET FILES STORE, COPY FILE, RENAME FILE, and DELETE FILE statements. You can also attach event handlers to the TEDBSession OnStatusMessage and OnProgress events in order to track any status messages and progress during a file copy operation.

Types of Stores
Stores can be created as either local or remote, and they are defined as follows:

TypeDescription
LocalA local store simply points to a local path that is accessible from the current process.
RemoteA remote store is a "virtual" store that is defined locally but actually points to another store on a remote ElevateDB Server. This abstraction of remote stores make the stores very useful because you can transfer files between different machines by simply copying a file from a local store to a remote store, and vice-versa.

Creating a Store
To create a store, you can use the CREATE STORE statement. If, at a later time, you wish to change the store from a local store to a remote store, or vice-versa, you can do so by using the ALTER STORE statement.

Adding Files to a Store
Adding files to a local store can be done via the operating system itself by copying or moving files into the local path used by the local store. However, many times the files will be created using statements such as the BACKUP DATABASE, SAVE UPDATES, or EXPORT TABLE statements. These statements require a local store as the location where the files generated by these operations will be created.

You can also use the COPY FILE, RENAME FILE, and DELETE FILE statements to manipulate files in a given local or remote store. This makes stores very useful because they use the existing ElevateDB remote communications facilities and don't require any extension configuration of the operating system to set up virtual private networks (VPNs) or other elaborate setups.

For example, here's an example of using the COPY FILE statement to copy a backup file from a local store to a remote store.

begin
   MySession.Execute('COPY FILE "MyBackup.EDBkp" IN STORE "LocalStore" '+
                     'TO "MyBackup.EDBBkp" IN STORE "RemoteStore"');
end;

Tracking the Copy File Progress

To take care of tracking the progress of copying files we have provided the OnProgress and OnStatusMessage events within the TEDBSession component. The OnProgress event will report the progress of the file copy operation and the OnStatusMessage event will report any status messages regarding the file copy operation.

Retrieving Information About Files
To retrieve information about the files in a specific store, you can use the SET FILES STORE statement to specify the store where the files are located, and then use a SELECT statement to query the Files Table in the Configuration Database. The Files table contains information about all of the files in the store specified by the SET BACKUPS STORE statement, with one row per file. Please see the Executing SQL Statements for more information on executing a query.
Image