I'm using Firebird's isql.exe
tool to query an existing database:
isql -u <username> -p <password> <database> -i <file.sql> -o <output.txt>
This reads my SQL statements from file.sql
and saves the results to output.txt
.
Is there a way to feed the SQL statements into isql
via command line, and not from a file?
This is because I actually plan to execute the command above in my .exe installer script (via ExecWait
of NSIS Installer).
Also, is there a way to format the output such that only the actual info needed are returned? Currently the output's first line contains the column names, second line a bunch of "====" as separator, third line the actual info, with an arbitrary number of spaces in between each column. This output format makes it hard for me to use in my script.
For your first problem, you can use Firebird isql without an input file as:
echo select * from rdb$database; | isql -u sysdba -p password C:\path\to\db.fdb
This redirects the standard output from echo (value select * from rdb$database;
) to the standard input of isql. The result of the query (or queries) will be printed to the standard output of isql (or to file if you use -o
).
However as echo is a feature of the command prompt, I am not certain if this will work from NSIS. Otherwise you will need something that does the same thing as echo: print its parameter values to the standard out.
As I commented before, for your second question you should look at SET HEADING
and maybe SET WIDTH
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With