Any file that is stored in the file system can be opened via the File | Open menu (Ctrl+O) and will be displayed under its file name in a new SQL Editor window.
If an SQL file that has already been added to the project, it can be opened from the Project window and will be displayed under its file name in a new SQL Editor window. A file that has been added to the Global Resources can be opened via the File | Open | Open Global Resource... menu and will be displayed under its Alias name in a new SQL Editor window.
To open an SQL file:
Do one of the following:
|•||Select the menu option File | Open | Open File... or press Ctrl+O. The standard Windows Open dialog box appears. Select an SQL (*.sql) file and click Open.|
|•||In the Project window, in the SQL folder do one of the following:|
|•||Select an SQL file and double-click the file name.|
|•||Right-click the file and select Open from the context menu.|
The SQL file is displayed in a new SQL Editor window.
|•||Select the menu option File | Open | Open Global Resource... to display the Choose Global Resource dialog box and do one of the following:|
|•||Select a file-type global resource under the Files directory and click OK. The file is displayed under its Alias name in a new SQL Editor window.|
|•||Select a folder-type global resource under the Folders folder and click OK. The standard Windows Open dialog box appears and displays the content of the directory that is defined for the active configuration. Select a file and click Open. The file is displayed under its file name in a new SQL Editor window.|
Alternatively, do the following:
|1.||Select the menu option Tools | Global Resources or, in the Global Resources toolbar, click the Manage Global Resources button.|
|2.||Under the Files folder, click the Alias name of the SQL file you want to open.|
|3.||Click the View button. The file is opened with the configuration that is selected in the drop-down list of the Global Resources toolbar. If the selected configuration is not applicable, the SQL file opens with the Default configuration.|
It may occur that a script contains parsing errors when it is first displayed in the SQL Editor. If, for example, the execution blocks are not set correctly, such a script would produce an error when being executed. (To check the execution blocks, toggle on the Show groupings for execution icon.) Also the syntax highlighting may not be displayed correctly when the script is initially parsed or edited by the user. To correct such errors, the SQL Editor toolbar provides the Reparse the whole document button.
To correct a SQL script with parsing errors:
|•||In the SQL Editor toolbar, click the Reparse the whole document button.|
Saving and closing
DatabaseSpy offers several options for saving SQL statements in, or closing one or several windows of, the SQL Editor:
|•||Save: saves the contents of the active window to the file from which it has been opened.|
|•||Save As: pops up the familiar Windows Save As dialog box, in which you enter the name and location of the file you wish to save the active file as.|
|•||Save All: saves all modifications that have been made to any open documents.|
|•||Close: closes the active window.|
|•||Close All: closes all open windows.|
|•||Close All But Active: closes all open windows but leaves the active file open in the SQL Editor.|
For all Close commands, if the file was modified (indicated by an asterisk * after the file name in the title bar), you will be asked if you wish to save the file first.
All commands except Close All But Active are available in the File menu, and all commands that affect only one particular window are included in the context menu that opens when you right-click the tab of the respective SQL Editor window.
In addition to the menu commands listed above, you can also use the keyboard shortcut Ctrl+S to save the active SQL file.
Saving SQL scripts
You can save any SQL that appears in an SQL Editor window and re-use the script later on. If the content of an SQL Editor window has already been saved, the file name appears in the title bar of the SQL Editor window. Unsaved files can be identified by the asterisk to the right of the generic title in the title bar.
A saved SQL script can be made available for all Altova applications by defining it as a global resource. Global resources can be used in all Altova applications that share the same Global Resources XML File.
To save the content of an SQL Editor window to a file:
|1.||Do one of the following:|
|•||Right-click the tab of the respective SQL Editor window and choose Save... from the context menu.|
|•||Make the SQL Editor window you want to save the active window and press Ctrl+S.|
|2.||If you save the file for the first time, choose a name and path for the file in the Save As... dialog box and click Save.|
To save an SQL file under a new name:
|1.||Right-click the tab of the respective SQL Editor window and choose Save As... from the context menu.|
|2.||In the Save As... dialog box, choose a new name and path for the file and click Save.|
© 2019 Altova GmbH