Export SQL Query (DbSql) |
Description:
DbSQL allows you to run any SQL statement/query and export the result
to XML(default), CSV, TXT or HTML format.
You can specify a query name with the -n option if you want to permanently
store the new SQL Query in the database, otherwise it will be just an ad-hoc
query.
DbQuery writes the output by default to 'in.fmt' (in: input filename)
(fmt:XML, CSV, TXT or HTM)
unless you
specify with '-o' a different output file.
If you specify '-' as the output file DbSql will write to the standard output
Numeric columns are exported right justified in HTML format.
If the query requires input parameter, DbSql will read the
in.par file
and use one line for each parameter.
DbSql writes all diagnostics to a log file "logs/yyyymmdd/DbQSql.log"
Note that In demo mode up to 100 records can be exported.
Syntax:
usage: dbsql [-sa] [-f{fmt}] [-d{db}] -i{in} [-o{out}] [-n{name}]
-f = FORMAT : Specify output format: XML,CSV,TXT,HTM (default XML)
-d = DATABASE: Specify database input file (default Sample.mdb)
-i = INPUT : Specify SQL input filename (required)
-o = OUTPUT : Specify output file (for STDOUT use '-', default {name.fmt})
-n = NAME : Specify name of new query (To save SQL in Database)
-s = SILENT : Dont show diagnostics (XX Records written..)
-a = NOADD : Dont run query (just add to database)
(For Query parameter use {In}.par - use one line for each parameter
Example1 (Default XML export):
DbSql -d Sample.mdb -i EmployeeSales.sql
Written 16 record(s) to EmployeeSales.xml
DbSql has exported 16 records to EmployeeSales.XML
and written the structure to EmployeeSales.DTD
DbSql used the EmployeeSales.par for reading
the Begin/End date parameter:
11/1/94
11/15/94
Example2 (HTML export to specified output
file):
DbSql -f htm -d Sample.mdb -i EmployeeSales.sql
-n EmpSales
-o EmpSales.htm
Written 16 record(s) to EmpSales.csv
DbSql has exported 16 records to EmpSales.htm
DbSql also added the
EmployeeSales.sql
SQL query
permanently to the database under the name "EmpSales"
Logfile:
If you run this command on Feb 18th, 2001 the logfile
would be created in:
logs/20010218/dbsql.log
INIT |12:01:41.174 |====== Opening
C:/DbTkXml/logs/20020309/dbsql.log ======
DbTkXml|12:01:41.285 |ExecCmd: opendb Sample.mdb
DbTkXml|12:01:41.365 |ExecCmd: runsql EmployeeSales.sql|EmpSales|EmpSales.csv|htm
RunSQL |12:01:41.485 |Written 16 record(s) to EmpSales.csv