Question

I am facing a problem in DB2. In my Oracle environment it was very easy for me to include multiple scripts in one master script, which were executed sequentially. e.g.: Master.sql:

  • connect ....
  • @script1.sql
  • @script2.sql

Now I have to build up same logic in DB2 LUW. Is there a simple way to include multiple scripts in one master script? I would like to have one single db2 call from shell, which executes the master script and within all subscripts.

Regards Jan

Était-ce utile?

La solution

There is notrhing to stop you from creating a single file with multiple sql batches. In the Windows world, it would look like this:

Note: First you initialize the db2 command prompt.

 db2cmd -c -w -i %1.bat

With as many of these as you want in the .bat file:

 db2 -txf c:\Example\db2html.sql

Autres conseils

In Linux, the db2clp is included in the shell once you load the db2profile ('. /home/db2inst1/sqllib/db2profile). In windows, you need to call db2cmd in order to use db2clp.

With a interactive db2clp, you cannot call db2 scripts via @scriptX, however, you can call them from the shell like

db2 -tvf script

However, if you use the CLP*Plus you can do almost everything you do in SQL*Plus. For more information: https://www.ibm.com/developerworks/community/blogs/IMSupport/entry/tech_tip_db2_s_new_clp_plus_utility?lang=en

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top