If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > SQL in a batch file... strange

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-04-03, 13:02
M2001 M2001 is offline
Registered User
 
Join Date: Jan 2003
Posts: 14
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
Reply With Quote
  #2 (permalink)  
Old 03-08-03, 06:29
eherber eherber is offline
Registered User
 
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
***********************************************
Reply With Quote
  #3 (permalink)  
Old 03-12-03, 19:21
SSSimon SSSimon is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On