Database Tour Documentation Contents Index

Command Line Usage: Open a Database

Top Previous Next

This topic describes parameters of Database Tour command line, specific to opening a database and performing some additional tasks in it. This type of command line can be used only in Database Tour Pro.

Common rules for writing command lines are described here.

Before you start...

Advanced users can build the needed command line manually using the specification below. But if you are a beginner or just need to create a command line for simple operation, you can save your time using Database Tour command line builder. To generate a command line, choose 'Tools | Generate Command Line | Open a Database...' menu. In 'Generate Command Line' window, specify needed options and click OK. A new window will appear with the command line generated. Copy it, correct it if it is needed, and use in Database Tour calls from your own programs, .bat files etc.

Please note that the command line builder cannot generate any type of command line. It produces only generic command lines which is enough for the most of needs and good point to start from. Generated command line can be easily changed manually for more complex tasks.

Usage (specification):

Long (classic) format:
    dbtour.exe [/silent] </opendb> [/minimize] [/CloseWhenDone] [/CloseOnError] [/LogFile=LogFileName] [/AppendLog] [/UseParadoxPasswords=ParadoxPasswords] [/DBInterface=ado|bde|interbase] [/DBKind=DBKind] [/DBDriver=DBDriver] [/DBUserName=UserName] [/DBPassword=Password] [/DB=DBName] [/TableName=TableName] [/SQLFile=SQLFileName] [/ExecuteQuery] [/ColDefsFile=FileWithColumnDefinitions] [/SQLStatementSeparator=SQLStatementSeparator] [/ReportTemplateFile=ReportTemplateFileName] [/NoReportBuilder] [/ReportPreview] [/SQLParamNames=ParamName1%#%ParamName2%#%...] [/SQLParamValues=ParamValue1%#%ParamValue2%#%...] [/SQLParamTypes=ParamType1%#%ParamType2%#%...] [/SQLMacroNames=MacroName1%#%MacroName2%#%...] [/SQLMacroValues=MacroValue1%#%MacroValue2%#%...] [/ReportVarNames=VariableName1%#%VariableName2%#%...] [/ReportVarValues=VariableValue1%#%VariableValue2%#%...]
     
Short format (parameters are excluded from the command line and included in the action file):
    dbtour.exe [/silent] [/ParamsFile=ActionFileName]

Examples:

1. Open a Microsoft Access database and load SQL text from a file
dbtour.exe /opendb "/DB=c:\my db\stores.mdb" "/SQLFile=c:\my db\TodaysPayments.sql"

2. Open a folder based DBF database and open a table in it
dbtour.exe /opendb /DBInterface=ADO /DBDriver=dBase /DBKind=FOLDER "/DB=c:\MyData" "/TableName=customer.dbf"

3. Open a DSN based Oracle database, load an SQL script, and open a table in it
dbtour.exe /opendb /DBInterface=ADO /DBDriver=Oracle /DBKind=DSN "/DB=MyOraDSN" "/TableName=myschema.address_data" /SQLFile=d:\MyScripts\CopyData.sql /PrimaryDataset=Table

4. Open a connection string based Oracle database, execute an SQL script in it, and then close all
dbtour.exe /opendb /DBInterface=ADO /DBDriver=Oracle /DBKind=CONSTR "/DB=Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;" /DBUserName=JohnM /DBPassword=qazwsx78 /SQLFile=d:\MyScripts\CopyData.sql /ExecuteQuery /CloseWhenDone

5. Open an Interbase database, execute an SQL script in it, and then close all
dbtour.exe /opendb /DBInterface=INTERBASE /DBDriver=INTERBASE /DBKind=FILE "/DB=MyServerName:D:\CommonData\News.gdb" /DBUserName=JohnM /DBPassword=qazwsx78 /SQLFile=d:\MyScripts\CheckData.sql /ExecuteQuery /CloseWhenDone

6. Open an Interbase database via ADO, open an SQL query in it, and load a report template
dbtour.exe /opendb /DBInterface=ADO /DBDriver=INTERBASE /DBKind=FILE "/DB=MyServerName:D:\CommonData\News.gdb" /DBUserName=JohnM /DBPassword=qazwsx78 /SQLFile=d:\MyScripts\LastIncome.sql /ExecuteQuery /ReportTemplateFile=d:\MyReports\LastIncome.dtt

7. Open a Paradox table and load column definitions for it
dbtour.exe /opendb /DBInterface=BDE /DBDriver=Paradox /DBKind=FOLDER "/DB=c:\MyData" "/TableName=orders.db" "/ColDefsFile=c:\MyData\orders.dcl

8. Open a connection string based MySQL database
dbtour.exe /opendb /DBInterface=ADO /DBDriver=MySQL /DBKind=CONSTR "/DBUserName=StacyO" "/DB=Provider=MySQLProv;Data Source=mydb;User Id=myUsername;Password=myPassword;"

9. Open a DSN based Oracle database, load and execute parameterized SQL script in it, and then close all. When error is occured, close the database and program. All execution log must be saved to file. Everything should be done in 'silent' mode.
dbtour.exe /silent /opendb /DBInterface=ADO /DBDriver=Oracle "/DB=<DSN>MyOraDSN" /DBUserName=Bohdan2000 /DBPassword=tobein2010 /SQLFile=d:\MyScripts\UpdateProducts.sql /ExecuteQuery /SQLParamNames=PDate%#%PProdCategory%#%PProdChannel /SQLParamTypes=Date%#%Integer%#%String /SQLParamValues=2014-02-02%#%12%#%Direct /CloseWhenDone /CloseOnError /LogFile=d:\out\logs\UpdateProducts.log

10. The same as the previous one but using an action file
dbtour.exe /silent "/ParamsFile=c:\DBTourStartParameters.txt"

The contents of c:\DBTourStartParameters.txt file should be like the following:

 

;main action
/opendb

;db definition
/SrcDBInterface=ADO
/DBDriver=Oracle
/DB=<DSN>MyOraDSN
/DBUserName=Bohdan2000
/DBPassword=tobein2010

;actions
/SQLFile=d:\MyScripts\UpdateProducts.sql
/ExecuteQuery
/SQLParamNames=PDate%#%PProdCategory%#%PProdChannel
/SQLParamTypes=Date%#%Integer%#%String
/SQLParamValues=2014-02-02%#%12%#%Direct

;options
/CloseWhenDone
/CloseOnError
/LogFile=d:\out\logs\UpdateProducts.log

Description of the options:

Option Description
/OpenDB Tells the program to open certain database and (optionally) perform some actions in it.
/silent This switch will run the program in "silent" mode, without any windows (except purchase reminder when the program is used without registration after the test period). When using /ParamsFile option, /silent switch must be outside parameters file. Attention! There are no overwrite or other prompts in this mode.
/ParamsFile Specifies the name of the action file, which contains command line parameters, one parameter per line. Lines with a semicolon at the beginning are ignored as comments. Blank lines are allowed. When using this option, there should not be other command line parameters in the command line except /silent switch. If the file name includes spaces, entire parameter must be enclosed in quotes. See example 10.
/UseParadoxPasswords Semicolon separated list of passwords for Paradox tables (only for BDE connections).

/DB

Specifies name of source database to open. This can be a file name, folder name, ODBC DSN, BDE alias name, or connection string. If the name includes spaces, entire parameter must be enclosed in quotes. If the name is an ADO connection string with quotes inside, it is recommended to use the short format of command line (using the parameters file).
/DBInterface Specifies database interface (database engine) used to connect the source database. Possible values: ADO, BDE, INTERBASE. If not specified, the program will use ADO.
/DBKind Specifies source database kind. Possible values: FOLDER, FILE, DSN, CONSTR; the last one must be used only for ADO interface (see /DBInterface description). If not specified, the program will try to detect it automatically.

Instead of using this parameter, it is possible to use a prefix specifying the database kind (file, folder, ODBC DSN, connection string) in the /DB parameter. The prefix must be enclosed in arrow brackets <>. Possible values: <FILE>, <FOLDER>, <DSN>, <CONSTR>. It is recommended to enclose the entire parameter in quotes in such cases. See example 9.

/DBDriver Specifies source database driver. Examples of possible values: ACCESS, DBASE, INTERBASE, FIREBIRD, ORACLE, SQL SERVER, etc. If not specified, the program will try to detect it automatically. If the driver name includes spaces, entire parameter must be enclosed in quotes.
/DBUserName Specifies user name for source database. If the user name includes spaces, entire parameter must be enclosed in quotes.
/DBPassword Specifies password for source database. If the password includes spaces, entire parameter must be enclosed in quotes.
/TableName Specifies a source table name to open. If this parameter is omitted and the source database is file, the program will try to extract it from /DB. This parameter should not be used with /silent switch. If the name includes spaces, entire parameter must be enclosed in quotes.
/SQLFile Specifies a file name to load SQL text from. The file can also be a multi-statement SQL script; in this case different statements must be separated by /SQLStatementSeparator. The SQL query (queries) from the file will not be executed until /ExecuteQuery switch is used. This parameter should not be used with /silent switch. If the name includes spaces, entire parameter must be enclosed in quotes.
/ExecuteQuery Tells the program to execute SQL query (queries) which was loaded from /SQLFile.
/PrimaryDataset If both /TableName and /SQLFile switches are used in one command line, the program will open two pages (tabs): one for the table and another one for the query. This switch tells the program which of them should be active. Possible values: Table, Query.
/SQLStatementSeparator

Specifies separator of SQL statements (SQL terminator) if /SQLFile is a multi-statement SQL script. Can be any character or character code, followed after # symbol. There is also a predefined separator, called sqlplus, which is usually used in Oracle SQL Plus utility and other Oracle specific tools and utilities; this is a slash (/) on a separate line between two statements. Default value for SQL statement separator is semicolon (;).

/SQLParamNames Can be used in cases, when /SQLFile contains a parameterized SQL query (or queries). SQL text of parameterized query contains parameter(s) for dynamic replacement; each parameter starts with colon, for example, :ITEMID, :PAYDATE and so on. SQL parameters are processed on database engine or database (for server databases) level. Use this switch to define a list of parameter names, which should be automatically replaced before the query execution. This list must contain parameter names (the colon must be omitted here) separated by %#% character combination. If the switch contains spaces, it should be enclosed in quotes. This switch must be used in conjunction with /SQLParamValues and /SQLParamTypes switches. See examples above.
/SQLParamValues List of SQL parameter values separated by %#% character combination. The number of items in the list and their positions must match the ones from /SQLParamNames switch. To pass null value, text of the value should be NULL (in upper case). If the switch contains spaces, it should be enclosed in quotes.
/SQLParamTypes List of SQL parameter types separated by %#% character combination. The number of items in the list and their positions must match the ones from /SQLParamNames switch. Available types: Boolean, Currency, Date, DateTime, Float, Integer, SmallInt, String, Time, Word. The switch should not contain spaces.
/SQLMacroNames

Can be used in cases, when /SQLFile contains an SQL query (or queries) with macros. SQL text of such queries contains macro(s) for dynamic replacement; each macro starts with << and ends with >>, for example, <<ITEMID>>, <<PAYDATE>> and so on; unlike parameter, macro does not have a type and is always inserted as text. Use this switch to define a list of macro names, which should be automatically replaced before the query execution. This list must contain macro names (separators << and >> must be omitted here; macro name should contain only alphanumeric characters) separated by %#% character combination. The macros are processed before processing of parameters; therefore it is possible to use macros inside parameters. If the switch contains spaces, it should be enclosed in quotes. This switch must be used in conjunction with /SQLMacroValues switch. See examples above.

/SQLMacroValues List of SQL macro values separated by %#% character combination. The number of items in the list and their positions must match the ones from /SQLMacroNames switch. If the switch contains spaces, it should be enclosed in quotes.
/ReportVarNames

List of global report variables, which initial values must be overridden. Multiple items must be separated by %#% character combination. If the switch contains spaces, it should be enclosed in quotes. This switch must be used in conjunction with /ReportPreview switch.

/ReportVarValues List of initial values of global report variables. Multiple items must be separated by %#% character combination. The number of items in the list and their positions must match the ones from /ReportVarNames switch. If the switch contains spaces, it should be enclosed in quotes.
/CloseWhenDone Forces the program to close itself after successful query execution. This option is ignored in "silent" mode where the program is closed automatically anyway.
/CloseOnError Forces the program to close itself when error occurs during the command line execution. This option is ignored in "silent" mode where the program is closed automatically anyway.
/minimize Program starts in minimized mode. It is restored to normal mode on error or after ending execution (if /CloseWhenDone switch is not used). This option is ignored in "silent" mode where the program runs without any windows.
/LogFile Specifies the name of the file to write operation log. If the name includes spaces, entire parameter must be enclosed in quotes.
/AppendLog Specifies that log of the operations should be written from the end of the log file with saving the previous file content. If this switch is omitted, existing log file will be fully overwritten.
/ColDefsFile Specifies name of a file with column definitions. The column definitions will be applied only to page of primary dataset (see description of /PrimaryDataset). If the name includes spaces, entire parameter must be enclosed in quotes.
/ReportTemplateFile Specifies name of a file with report template. In this context, the database and dataset definitions from the report template will be ignored, and report template will be applied currently opened primary dataset (see description of /PrimaryDataset). If the name includes spaces, entire parameter must be enclosed in quotes.
/NoReportBuilder Tells the program not to open report builder after the /ReportTemplateFile was loaded (default behaviour is to load the report builder).
/ReportPreview Tells the program to open report preview after the /ReportTemplateFile was loaded.