Command «dbrequest»

This command is used to execute directly requests to specified in parameters database table. Command allows executing insert, update, any stored procedures, any SQL statement.

General Syntax

Here is general command statement syntax:

cmdmgr.exe dbrequest [--section=section_name] --sqlstatement=<"SQL text"> | statement<select|insert|update|sp> [additional paramters]

There two general types of statements:

  • any SQL statement. This statement required «sqlstatement» parameter that must contain SQL query;

  • standard statements. This is select\insert\update or stored procedure statements. «statement» parameter must contain statement type. Command manager support such statements: select, update, insert, sp.

Here are syntaxes for every statement type.

1. «select» statement

cmdmgr.exe dbrequest [--section=section_name] --statement=select --table=PREFIX.TABLE_NAME --columns="Col1,Col2,ColN" --conditions="Cond1>1,Cond2!=2,Cond3=3" [--df | disableformatting] [--maxrows=25] [--asis] [--xml]

Parameters

After execution result will be in output stream. Here are parameters that use this statement:

  • table – this is database table for which statement is executing. This must be table name with prefix;

  • columns – columns of specified table that will be selected. To select all columns, pass «*» as value;

  • conditions – conditions for statement execution. Can be empty.

Example

cmdmgr.exe dbrequest statement=select --table=eaglemgr.dbo.cmdmgr_test_table --columns="*" --conditions="ID<3" --df -asis
Select example

2. «update» statement

Parameters

Execution of this statement will only print error or success message. Here are statement parameters:

  • table – as with «select» statement this is database table for which statement is executing. This must be table name with prefix;

  • values – this is «column=value» list of columns that statement will update;

  • conditions – conditions for statement execution. This parameter cannot be empty.

Example

Update example

3. «insert» statement

Parameters

Execution of this statement will print only success or error message and rows count affected. Here are statement parameters:

  • table – this is database table for which statement is executing. This must be table name with prefix;

  • values – list of «column=value» parameters that statement will insert to table.

Example

4. stored procedure («sp») statement

Parameters

Based on stored procedure type, this statement execution can print data as in «select» statement to output stream. Here are statement parameters:

  • sp – name of stored procedure in database. Format is Schema.SpName;

  • arguments – this is «arg_name=value» list of stored procedure arguments.

Example

5. any SQL statement

Parameter

This statement allows to execute any user defined SQL query. Statement has only one parameter that must be specified:

  • sqlstatement – this is user defined SQL query that will be executed. As in «select» statement, if user defined SQL query, returns any result data, it will be printed to output stream;

Example

 

Most statements have optional parameters that are the same in any context. Here are these parameters and their descriptions:

  • section – this is section from db_connection.ini. By default, primary section used;

  • df(disableformatting) – switches off advanced output formatting;

  • maxrows – maximum rows count to output;

  • asis – print output data, without replacing data to columns type (<BLOB>, <CLOB>, <XML> , and so on);

  • xml – output will be formatted in XML. If this parameter is specified, --asis and --disableformatting will be ignored.