Skip to main content

Problem:

How can a number of SQL files be run from a .BAT file, without any XDB / SQL Wizard prompts that need responses.

Resolution:

The BAT file.

The attached example (phbatch.bat) has the following statements in them.

start /MIN xsrv40n                                             

          ---  this line will start the xdb server

sleep 80                                                            

          ---  this requires sleep software installed on your machine to make sure the server starts                 prior to the next command

start start40n /name=install /pass=                     

          ---  this line makes sure the userid and password prompt does not display. Enter a valid                 username.  Omit the /pass= if there is no password associated with the user Id                 (superuser)    

MFEENV.EXE XWIZ40N.EXE "d:\\mfe30projects\\p2150001\\sql\\phsql1.sql"                        

           ---  this runs the .sql file (which is in the same path or a path would need to be specified)

stop40n                                                           

           ---  this makes sure SQLWizard shuts down

The SQL file.

The attached examples (phsql1.sql and phsql2.sql) has the following statements in them.

SELECT * FROM TUTORIAL.TUTORIAL.EMPLOYEE;                 

                   --  this runs the select statement

NODISPLAY;      

                 --  this makes sure nothing is displayed so SQLWizard does not pop-up  on your screen

DUMP phemp.out;

                --  this pipes the data from the employee table to a file called phemp.out in this same                          directory as the directory containing the .bat file.

( NOTE :- When the SQL is run for the first time,  the .out file will be created.  Any subsequent time this is run, the results will be appended to the previous results in the file. )

Attachments:

phbatch.bat

Old KB# 2409

#EnterpriseDeveloper
#MFDS