Firebird iSQL - how to enter SQL query from command line and extract output in simpler format
I am using Firebird tool isql.exe
to query an existing database:
isql -u <username> -p <password> <database> -i <file.sql> -o <output.txt>
which reads my SQL statements from file.sql
and stores the results in output.txt
.
But is there a way to feed SQL statements to isql
via the command line rather than from a file?
This is because I am actually planning on executing the command above in my .exe script ExecWait
installer (via NSIS installer).
Also, is there a way to format the output so that only actual information is returned? Currently, the first line of the output contains the names of the columns, the second line is the "====" link as a separator, the third line is the actual information with an arbitrary number of spaces between the columns. This output format makes it difficult to use in my script.
source to share
For your first problem, you can use Firebird isql without an input file like:
echo select * from rdb$database; | isql -u sysdba -p password C:\path\to\db.fdb
This redirects stdout from echo (value select * from rdb$database;
) to isql stdin. The result of the query (or queries) will be printed to isql standard output (or a file if you are using -o
).
However, since echo is a command line symptom, I'm not sure if this will work from NSIS. Otherwise, you need something that does the same thing as echo: print its parameter values ββto the default.
As I said, for your second question, you should look SET HEADING
and maybe SET WIDTH
.
source to share
In case others find it helpful, I was actually able to implement this in NSIS using $PLUGINSDIR
which is a temporary folder created by NSIS at runtime. I created a temporary input and output file in this folder. I wrote the SQL statements to an input file with FileWrite
and read the output withFileRead
source to share