Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Batch db2 - Windows - How To???

2 views
Skip to first unread message

Zasha Weinberg

unread,
Nov 21, 1997, 3:00:00 AM11/21/97
to

I'm trying to run the DB2 command processor in batch mode from a Windows NT
service. This is supposed to periodically backup various tables, and send
the data to another site.

The problem is the way db2cmd.exe seems to work. It doesn't work it the
way that I'd expect for batch processing.
Problem #1: db2cmd.exe creates a child process cmd.exe such that, after
db2.exe is finished, cmd.exe is still running. This means that the cmd.exe
will hang around in memory forever.
Problem #2: db2cmd.exe seems to create the cmd.exe child process and then
exit. This makes it difficult to know when the cmd.exe exits (and I want
to wait for it).
Problem #3: db2.exe refuses to run without db2cmd.exe, claiming that the
command environment is not initialized.

Is there a way to use this such that it works in the normal way you'd
expect for batch processing? For example, isql on Microsoft SQL Server, or
sqlplus on Oracle on Solaris (and probably most things on UNIX).

-Z.

P.S.: In the meantime, I've done 2 (I think) ridiculous hacks:
#1: In the binary of db2cmd.exe, you can see a string where it runs 'cmd
/k'. I changed the /k to /c, which makes the cmd.exe exit after running
it's child.
#2: As a last step, the input file to db2 makes it export a table to a
dummy file. The service checks for the existance of the file to see if
db2.exe is finished.
This shouldn't be necessary.

Kai-Uwe Schwarzwaelder

unread,
Nov 25, 1997, 3:00:00 AM11/25/97
to Zasha Weinberg

--------------A4C16CC04AC38D41AADE918F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

I use DB2/NT4.0 and use some perl scripts to perform DB2 import/export
create tables and insert/update jobs. To do this periodical, i use the
NT Services. I create a batch file like test.bat, that change in the
directory of the perl programms, and call the programm like this: perl
test.pl. After all batch-statements i call exit. To start this batch
file periodically, i add the command db2cmd test.bat to WinAt.

Kai.
--
----------------------------------------------------------------
Kai-Uwe Schwarzwaelder |
NEUROTEC Hochtechnologie GmbH | Division Multimedia
Ehlersstr. 15 | 88046 Friedrichshafen
Tel. +49 07541 3012 0 | Fax. +49 07541 33013
Email k...@neurotec.de | http://www.neurotec.de


--------------A4C16CC04AC38D41AADE918F
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>

<BLOCKQUOTE TYPE=CITE>I'm trying to run the DB2 command processor in batch


mode from a Windows NT

<BR>service.&nbsp; This is supposed to periodically backup various tables,
and send
<BR>the data to another site.

<P>The problem is the way db2cmd.exe seems to work.&nbsp; It doesn't work
it the
<BR>way that I'd expect for batch processing.
<BR>Problem #1: db2cmd.exe creates a child process cmd.exe such that, after
<BR>db2.exe is finished, cmd.exe is still running.&nbsp; This means that
the cmd.exe
<BR>will hang around in memory forever.
<BR>Problem #2: db2cmd.exe seems to create the cmd.exe child process and
then
<BR>exit.&nbsp; This makes it difficult to know when the cmd.exe exits
(and I want
<BR>to wait for it).
<BR>Problem #3: db2.exe refuses to run without db2cmd.exe, claiming that
the
<BR>command environment is not initialized.

<P>Is there a way to use this such that it works in the normal way you'd
<BR>expect for batch processing?&nbsp; For example, isql on Microsoft SQL
Server, or
<BR>sqlplus on Oracle on Solaris (and probably most things on UNIX).

<P>-Z.

<P>P.S.: In the meantime, I've done 2 (I think) ridiculous hacks:
<BR>#1: In the binary of db2cmd.exe, you can see a string where it runs
'cmd
<BR>/k'.&nbsp; I changed the /k to /c, which makes the cmd.exe exit after
running
<BR>it's child.
<BR>#2: As a last step, the input file to db2 makes it export a table to
a
<BR>dummy file.&nbsp; The service checks for the existance of the file
to see if
<BR>db2.exe is finished.
<BR>This shouldn't be necessary.</BLOCKQUOTE>
Hi,

<P>I use DB2/NT4.0 and use some perl scripts to perform DB2 import/export
create tables and insert/update jobs. To do this periodical, i use the
NT Services. I create a batch file like test.bat, that change in the directory
of the perl programms, and call the programm like this: perl test.pl. After
all batch-statements i call <I>exit</I>. To start this batch file periodically,
i add the command db2cmd test.bat to WinAt.

<P>Kai.
<BR>--
<BR>----------------------------------------------------------------
<BR>Kai-Uwe Schwarzwaelder&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |
<BR>NEUROTEC Hochtechnologie GmbH | Division Multimedia
<BR>Ehlersstr. 15&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
| 88046 Friedrichshafen
<BR>Tel. +49 07541 3012 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
| Fax. +49 07541 33013
<BR>Email k...@neurotec.de&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
| <A HREF="http://www.neurotec.de">http://www.neurotec.de</A>
<BR>&nbsp;</HTML>

--------------A4C16CC04AC38D41AADE918F--


Thomas Mittelstaedt

unread,
Nov 27, 1997, 3:00:00 AM11/27/97
to

I also launch db2cmd.exe from inside my application, which starts db2 with the
-f option to define a file, where to read commands from.

This file looks like the following:

CONNECT TO <host> USER <user> USING <password>;
IMPORT FROM D:\TEMP\ZMITTELST\PROJECT.ixf OF IXF MODIFIED BY FORCEIN MESSAGES
D:\TEMP\ZMITTELST\PROJECT.txt INSERT INTO ZMITTELST.PROJECT;
DISCONNECT <host>;

The messages options tells import to write results to the file PROJECT.txt.
This file can be evaluated periodically by the application that started db2cmd.
There are certain tags, present in all outputs. An example:

SQL3150N Der H-Satz in der PC/IXF-Datei enthält das Produkt "DB2 01.00",
das Datum "19971117" und die Uhrzeit "150523".

...giving a time stamp when the read of the IXF file started.

SQL3109N Das Dienstprogramm beginnt mit dem Laden von Daten aus der Datei
"D:\TEMP\ZMITTELST\GENPF850.ixf".

... the ixf file gets loaded.

SQL3221W ...COMMIT WORK beginnt. Zähler für Eingabesätze = "13".

SQL3222W ...COMMIT für alle Änderungen der Datenbank wurde erfolgreich
ausgeführt.

SQL3149N "13" Zeile(n) aus der Eingabedatei wurden verarbeitet. "13"
Zeile(n) wurden ohne Fehler der Tabelle hinzugefügt. "0" Zeile(n) wurden
zurückgewiesen.

.. the last should always be there telling you that the import operation
has completed.


Don't know better than that!

Hope that helps!

--Thomas

On Tue, 25 Nov 1997 09:09:42 +0100, Kai-Uwe Schwarzwaelder <k...@neurotec.de>
wrote:


천리안 NEWS GROUP 이용자

unread,
Dec 1, 1997, 3:00:00 AM12/1/97
to

Thomas Mittelstaedt (mitt...@biw-ag.de) wrote:
: I also launch db2cmd.exe from inside my application, which starts db2 with the

천리안 NEWS GROUP 이용자

unread,
Dec 1, 1997, 3:00:00 AM12/1/97
to
0 new messages