ExecSQL 1.3 Readme
==================

Copyright (c) 2003 DATO Software

Author:
=======
  Jerinic Stasa: stasa.jerinic@dato.at

Idea:
=====
  Bernd Maierhofer: bernd.maierhofer@dato.at

Description:
============

ExecSQL is an application for executing SQL Scripts. 
SQL statements are saved in external files and they can include macros. There are two different kinds of macros: 
1. #macro name# 
2. #[INC] [macro name] [max. macro value]#

ExecSQL is a command line tool, and all needed parameters and macro values (first macro kind under section Macros and second under section INC) can be defined either as command line parameters (for example: execsql /file=.\sqlscript.txt /[macros].Version=1.3), an INI file or in the registry.

The second macro kind will be also reread from command line, INI file or registry (under section INC and macro name under Key). If macro doesnt exist, the value will be set to one. This macro value will be increased every time, when the macro definition was found in SQL script.

For example:
     Following line is from script file
     ----------------------------------------------------------------------------
     insert into tsyuser values (15, #INC A 13#, #INC B 2#, #INC A 13#, Test)
     ----------------------------------------------------------------------------     
     If key A  and B doesnt exist neither in command line, INI file or registry the start value 
     will be set to one. The output line will look like this: 
     --------------------------------------------------
     insert into tsyuser values (15, 1, 1, 2, Test)
     --------------------------------------------------
    and after them the key A with value 2 and the key B with value 1 will be set into INI file, so 
    that this values are start values for the next using of them.

If the increased value achieves the maximal macro value, it would be set to one. 
This kind of macro could be used to fill the database with test data.

Comments are also possible between SQL statement lines. A comment line will be started with two minus (--).
To split the SQL statements use blank rows.

ExecSQL log failures will be recorded to the ExecSQL.txt file. In this file you can look after transaction failure protocol. 

In the section [DATA] can you set the database connections. See the INI file example below.

  PARAMETERS:
  ===========

  Parameters must be declared:
    /FILE       : This switch declares the path and name of SQL script file
  Other possible parameters:
    /TRANSACTION: This switch allows an application to perform explicitly and implicitly 
                  started transactions on a single connection
    /?          : This switch gives an overview of all registered switches.
                  Immediately afterwards the application terminates.
    /RegOff     : This switch starts the readout from the registry in or out. Default value is '-'.
    /IniOff     : This switch starts the readout from the ini file in or out. Default value is '-'.
    /CmdOff     : This switch starts the readout from the command line in or out. Default value is '-'.
    /RegPath    : This switch sets the path of the registry. 
                  Default value is '\Software\DATO\"Applicationname"\'.
    /IniPath    : This switch sets the path of the ini-file. Default value is "Application path".
    /IniFile    : This switch sets the name of the ini-file. Default value is '"Application name".ini'.
    /WriteIni   : This switch activates the writing of the registered switches into the ini-file.
                  Immediately afterwards the application terminates.
    /WriteReg   : This switch activates the writing of the registered switches into the registry.
                  Immediately afterwards the application terminates.
    /SHOWHIDDEN : This switch shows or hides the switches, which are registered with the special register method.
                  Default value is 'off'.
    /PrivatePath: This switch declares the private path. This path is needed for the LOG-file.
    /SystemPath : This switch declares the system path


  Example for a ini-file (ExecSQL.ini is in the same path, as the application)
  ============================================================================

    [PARAMETERS]
    PrivatePath=.\nkpsystem
    Transaction=-

    [DATA]
    Server=Data Source=MtBlanc2
    Database=Initial Catalog=nkp_test
    User=User ID=nkpdbaccess
    Password=Password=180659
    Provider=Provider=SQLOLEDB.1;Persist Security Info=True

    [Macros]
    DBNAME=nkp
    House=LAA
    Description=ExecSQL v1.0

    [INC]
    A=6
    C=1

      
  SQL Script File:
  ================

    -- (c) dato Denkwerkzeuge 2003 Wien
    -- Reorganisation and backup of database

    -- Transaction-Log shortening
    backup log #DBNAME# with no_log

    -- Database scaling down
    DBCC shrinkdatabase('#DBNAME#')

    -- Backup
    BACKUP DATABASE #DBNAME#
    TO DISK = 'D:\MSSQL\BACKUP\DASI_#DBNAME#_#INC A 7#.bak'
    WITH  INIT ,  NOUNLOAD ,  NAME = '#DBNAME# Sicherung',  
    NOSKIP ,  STATS = 10,  NOFORMAT 

    -- Add some inserts
    insert into tsyalias 
    values (15, '#INC A 7#', '#INC C 3#')

    insert into tsyalias
    values (16, '#House#', '#Description#')

    -- Add some updates
    update tsyalias
    set ALIASDESCRITPTION='#INC A 7#'
    where ALIASID=16

    -- End of doc


  SQL statements after running ExecSQL (with values from already shown INI File):
  ===============================================================================

    backup log nkp with no_log

    DBCC shrinkdatabase('nkp')

    BACKUP DATABASE nkp
    TO DISK = 'D:\MSSQL\BACKUP\DASI_nkp_7.bak'
    WITH  INIT ,  NOUNLOAD ,  NAME = 'nkp Sicherung',  
    NOSKIP ,  STATS = 10,  NOFORMAT 

    insert into tsyalias 
    values (15, '1', '2')

    insert into tsyalias
    values (16, 'LAA', 'ExecSQL v1.0')

    -- Add some updates
    update tsyalias
    set ALIASDESCRITPTION='2'
    where ALIASID=16


Contact:
========

  For further ideas or if you have any problems with ExecSQL please write an e-mail to: stasa.jerinic@dato.at.
  Please visit our homepage: www.dato.at


  
