Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Posts
    14

    Unanswered: SQL in a batch file... strange

    Hi,

    Informix on NT Server.

    Created this batch file contining the following commands in it:

    e:\informix\setenv
    dbaccess dbname file.sql

    When I try to execute the batch file, it executes the 'setenv' and then returns to the prompt without executing the 'dbaccess' part.

    One way around this is to have the contents of the actual setenv.bat file copied to my batch file above. Which work ok. The set commands gets executed as well as the dbaccess command.

    Any idea why the first option does not work.
    M2001

  2. #2
    Join Date
    Aug 2002
    Location
    Bonn/Germany
    Posts
    152
    I'm really no windows expert.

    On Unix systems you need to execute an environment
    file in the actual shell in order to set this environment
    in the current shell, for example:

    #!/bin/ksh
    /home/informix/.profile
    dbaccess stores7 select.sql

    This would not work because '/home/informix/.profile' will be executed in a sub-shell, thus the current shell would not get
    the actual environment. The right way would be:

    #!/bin/ksh
    . /home/informix/.profile
    dbaccess stores7 select.sql

    The leading point (". /home/informix/.profile") ensures that this
    file is executed in the current shell, thus the environment
    variables are available for the 'dbaccess' call.

    I don't know if this is the same in NT. You might echo the
    INFORMIXDIR and PATH environment variable after calling
    your 'setenv' batch file in order to see if the environment
    has been correctly set.

    Best regards

    Eric
    --
    IT-Consulting Herber
    WWW: http://www.herber-consulting.de
    Email: eric@herber-consulting.de

    ***********************************************
    Download the IFMX Database-Monitor for free at:
    http://www.herber-consulting.de/BusyBee
    ***********************************************

  3. #3
    Join Date
    Nov 2002
    Location
    Australia
    Posts
    8

    Lightbulb

    The reason the second line of your batch file doesn't work is because of the way you are calling the other batch file on the first line. Change your batch file to look like this:

    call e:\informix\setenv
    dbaccess dbname file.sql

    The call statement will then execute the setenv batch file, then return to this file to execute the second line.

    Simon.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •