The version that comes with Firebird 1.5 understands dialects.
This program
Running isql via Windows Explorer
This is a possible *.reg file - on some systems, the .sql key may already exist.
[HKEY_CLASSES_ROOT\.sql] @="sqlfile" [HKEY_CLASSES_ROOT\sqlfile\shell\isql\command] @="cmd.exe /k \"\"C:\\Program Files\\Firebird\\Firebird_1_5\\bin\\isql.exe\" -i \"%l\"\""Notice that
\" and \\
cmd.exe /k ""C:\Program Files\Firebird\Firebird_1_5\bin\isql.exe" -i "%l""
Comments
-- any comment, can use only one line
/* any comment, can use several lines */
However, there are several problems with the version of isql (dated 7-14-04) that come with Firebird 1.5.
Extra /*
Connect 'E:\NIST\Main Database\FB Databases 2005-02-11\Samples.fdb' USER 'SYSDBA' PASSWORD 'masterkey'; /* Data entered 02-22-05 - rlc used in Sample_Timeline_tbl to indicate the type of data CREATE TABLE "Data_Type_LU" ( "Data_Type_ID" "Domain_ShortString_IDs" NOT NULL, "Data_Type_Text" "Domain_Short_Descriptions", "Comment" VARCHAR(200) ); /* */with this error
Use CONNECT or CREATE DATABASE to specify a database Command error: /* Data entered 02-22-05 - rlc used in Sample_Timeline_tbl to indicate the type of data CREATE TABLE "Data_Type_LU" ( "Data_Type_ID" "Domain_ShortString_IDs" NOT NULL, "Data_Type_Text" "Domain_Short_Descriptions", "Comment"
If the comment is shortened to remove the last line of the error message and everything after it, the code does not fail.
Also, if the last line of the comment is changed from
/* */to
/* */
(ie, place a return between the 2 asterisks) there is no failure.
Failure Mixing Comment Types
Connect 'E:\NIST\Main Database\FB Databases 2005-02-11\Samples.fdb' USER 'SYSDBA' PASSWORD 'masterkey'; /* Any comment */ --Delete From "Barcode_Type_LU"; select 'Just a comment' from rdb$database;produces this error
Use CONNECT or CREATE DATABASE to specify a database Statement failed, SQLCODE = -104 Dynamic SQL Error -SQL error code = -104 -Unexpected end of command ============== Just a commentHowever, both of these run without error
The semicolon (;) at the end of the single line comment is removed
Connect 'E:\NIST\Main Database\FB Databases 2005-02-11\Samples.fdb' USER 'SYSDBA' PASSWORD 'masterkey'; /* Any comment */ --Delete From "Barcode_Type_LU" select 'Just a comment' from rdb$database;An sql statement is placed between the two types of comments
Connect 'E:\NIST\Main Database\FB Databases 2005-02-11\Samples.fdb' USER 'SYSDBA' PASSWORD 'masterkey'; /* Any comment */ select 'Just a comment' from rdb$database; --Delete From "Barcode_Type_LU"; select 'Just a comment' from rdb$database;In addition, you can not place single line (--) comments inside block comments.
isql Commands
Several other "special" commands are supported
? help; Show the available "special" commands
| help set;
| Show all the set options
| set;
| Show all the current option settings except dialect
| set terminator ^; | set terminator ;^ Change the command terminator to ^ and back to ;
| These commands are needed to define triggers and stored procedures set echo on;
| I use this to debug script errors when the script is run via a batch file
| input filename;
| Read additional commands from the specified file
| show table;
| List all the user tables
| show table "TableName";
| Show the table's structure - double quotes required for mixed case table names
| show system;
| List all the system tables - you should not edit these
| show sql dialect;
| This is how to see the set option, dialect 3 allows mixed case identifiers
| show domain;
| List the defined domains (field definition aliases)
| show domain "Domain_Name";
| This shows the definition of the alias (domain)
| show generator;
| Lists all generators and their current values
| |
Debugging Scripts
When running a script, it is likely that an error will be displayed ... but the command that caused the error will not be displayed.
There are 2 ways to display where the error is
set echo on;will display all the commands as they are executed. Use
set echo off;(the default) to hide them again.
You can also use a select statement to write a comment to the screen
select 'Just a comment' from rdb$database;produces
============== Just a comment
Registry Mods
Only show errors | cmd.exe /k ""C:\Program Files\Firebird\Firebird_1_5\bin\isql.exe" -i "%l""
Show All | Allows you to see which lines caused the errors cmd.exe /k ""C:\Program Files\Firebird\Firebird_1_5\bin\isql.exe" -e -i "%l""
| output -> debug.txt | Write to file cmd.exe /k ""C:\Program Files\Firebird\Firebird_1_5\bin\isql.exe" -e -i "%l" -o debug.txt"
| debug -> notepad | Write to file and then display it cmd.exe /k ""C:\Program Files\Firebird\Firebird_1_5\bin\isql.exe" -e -i "%l" -o debug.txt && notepad.exe debug.txt"
| |
For simple problems, I prefer to display the errors in the command window ... but for more complex errors, or large files where I want to search for the errors, then notepad is more convenient.
-i "filename" | Input file - may be fully qualified |
-o "filename" | Output file - may be fully qualified |
-e | Set echo on - causes the source file to be displayed so that the errors are associated with the correct statements |
-a | Display the metadata (table structures, triggers, etc) of an *.fdb file |
-u username | sysdba |
-p password | masterkey |
Registry Mods for *.fdb files
cmd.exe /c "del "%l.sql" & "C:\Program Files\Firebird\Firebird_1_5\bin\isql.exe"This command (actually entered on a single line, wrapped for readability) produces a file that contains the sql statements and then opens that file in notepad. Notice that cmd supports multiple commands separated by
-u SYSDBA -p masterkey -a "%l" -o "%l.sql" && notepad.exe "%l.sql""
& | Execute the next command as soon as possible |
---|---|
&& | Wait for previous command to finish without errors, then continue |