General isql Commands - Firebird

The general isql commands perform a variety of useful tasks, including reading, recording, and processing schema scripts, and executing shell commands. The commands are BLOBDUMP, BLOBVIEW, EDIT, EXIT, HELP, INPUT, OUTPUT, QUIT, and SHELL.

BLOBDUMP

stores BLOB data into a named file:

BLOBDUMP

Example:

SQL> BLOBDUMP 32:d48 IMAGE.JPG ;

BLOBVIEW displays BLOB data in the default text editor.

BLOBVIEW blob_id ;

BLOBVIEW

Example

SQL> BLOBVIEW 85:7 ;

Bug note: BLOBVIEW may return an “Invalid transaction handle” error after you close the editor. To correct the situation, start a transaction manually, with

SQL> SET TRANSACTION;

EDIT

allows editing and re-execution of the previous isql command or of a batch of commands in a source file.

SQL> EDIT [filename];Filename Optional, fully qualified filesystem name of the file to edit

Example:

SQL> EDIT /usr/mystuff/batch.sql

EDIT can also be used to open the previous statements in the editor:

SQL> SELECT EMP_CODE, EMP_NAME FROM EMPLOYEE ;
SQL> EDIT ;

Press Enter to display the “scroll” from your isql session in the default ASCII text editor in your system. Edit it, save it if you wish, and exit. The edited batch of commands will be re-executed in your isql shell when you exit the editor.

EXIT commits the current transaction without prompting, closes the database, and ends the isql session. If you need to roll back the transaction instead of committing it, use QUIT instead.

SQL> EXIT ;

EXIT takes no arguments.

HELP displays a list of isql commands with descriptions. You can combine it with OUTPUT to print the list to a file.

SQL> HELP ;

Example:

SQL> OUTPUT HELPLIST.TXT ; SQL> HELP ; SQL> OUTPUT ; /* toggles output back to the monitor */

HELP takes no arguments.

INPUT

reads and executes a block of commands from a named text file (SQL script). Input files can embed other INPUT commands, thus providing the capability to design chained or structured suites of DDL scripts. To create scripts, use a text editor or build them interactively, using the OUTPUT or EDIT commands.

SQL> INPUT filename ;

filename Fully qualified filesystem path to a file containing SQL statements and commands

Example:

SQL> INPUT /data/schemascripts/myscript.sql ;

In a script:

...
CREATE EXCEPTION E010 'This is an exception.';
COMMIT;
-- TABLE DEFINITIONS
INPUT '/data/schemascripts/tabledefs.sql';
-- CONSTRAINT DEFINITIONS
INPUT 'data/schemascripts/constraintdefs.sql';
...

OUTPUT

redirects output to a disk file or (back) to the standard output device (monitor). Use SET ECHO commands to include or exclude commands:

  • SET ECHO ON to output both commands and data
  • SET ECHO OFF to output data only
SQL> OUTPUT [filename]; SET ECHO commands

Example:

SQL> OUTPUT d:dataemployees.dta ;
SQL> SELECT EMP_NO, EMP_NAME FROM EMPLOYEE ; /* output goes to file */
SQL> OUTPUT ; /* toggles output back to the monitor */

QUIT

rolls back the current transaction and closes the isql shell.

SQL> QUIT ;

QUIT takes no arguments. If you need to commit the transaction instead of rolling it back, use EXIT instead.

SHELL gives temporary access to a command-line shell without committing or rolling back any transaction.

SQL> SHELL [operating system command];SHELL

Example:

SQL> SHELL dir /mydir | more ;

The example will display the contents of the directory /mydir and return control to isql when the display completes or the more utility is terminated by Ctrl+C.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Firebird Topics