Results 1 to 10 of 10
  1. #1
    Join Date
    Jul 2003
    Posts
    50

    Unanswered: db2batch - instance attach fails

    Hi

    I perform db2batch from my Windows-NT-db2-command-window (db2batch -d ADUSTONE -f sort.sql -a c149187/xxxxxx -r out.txt)
    on a remote Unix database and get the following: (udb 7.2)

    ----------------------------------------------------------------------------

    --#SET PERF_DETAIL 3 ROWS_OUT 5

    Statement number: 1

    select count(*) from sysibm.systables

    1
    --------------
    264


    Number of rows retrieved is: 1
    Number of rows sent to output is: 1

    SQL1428N The application is already attached to "DB2" while the command issued requires an attachment to "DINTADU" for successful execution.


    Elapsed Time is: 0.150 seconds


    Summary of Results
    ==================
    Elapsed Agent CPU Rows Rows
    Statement # Time (s) Time (s) Fetched Printed
    1 0.150 Not Collected 1 1

    Arith. mean 0.150
    Geom. mean 0.150

    ----------------------------------------------------------------------------

    -> The sql can be executed, but the instance attachment fails:
    SQL1428N The application is already attached to "DB2" while the command issued requires an attachment to "DINTADU" for successful execution.

    I tried to attach from my db2 window to DINTADU before executing db2batch, but it doesn't help. db2batch doesn't seem to know that the db ADUSTONE is on the instance DINTADU and not on DB2

    If I execute db2batch on a db on my PC, the everythinh works.

    -> Can db2batch not executed on a remote db ?

    Marc

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Try CATALOG TCP/IP NODE using the "REMOTE_INSTANCE instance-name" parm to associate the node with a particular instance. This assumes your protocol is TCP/IP. If not, use the other CATALOG commands for your protocol.

    Then you can ATTACH TO nodename.

  3. #3
    Join Date
    Jul 2003
    Posts
    50
    The IBM Client Configuration Assistant says:
    I have as instance node name DINTADU and its remote instance name is DINTADU also. The ATTACH TO from a db2 window is no problem, but it seems that db2batch attaches always to the local instance DB2 ???

  4. #4
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    I believe that with the catalog command that I mentioned you can create an alias (using a different name) to differentiate between the local and remote instance. I think you can do the same with CCA.

  5. #5
    Join Date
    Jul 2003
    Posts
    50
    Hi

    Can db2batch only be used for a local database, or can it be used also for remote database (I ask it because db2batch always does an implicit attach to the local db2instance)
    ?

    Marc

  6. #6
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    I think the database has to be catalogued locally as a remote database.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  7. #7
    Join Date
    Jul 2003
    Posts
    50
    The database is catalogued locally as a remote database. The SQL in the db2batch file (select count(*) from sysibm.systables) is exceuted correctly on the remote Unix database, so I think that the configuration is correctly.

    I start db2batch with -d adutest, the connect to the database adutest works, the sql result is correct.

    But when snapshot info's should be gathered as a second part of the db2batch-output, that requires an attach on the remote instance, db2batch doesn't know that the database adutest is in the remote instance adu, db2batch tries the local instance db2.

    I can't see that I have forgot something in the configuration !?

    Marc

  8. #8
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    OK, I see what the problem is:

    Setting the current instance Procedure:

    When you run commands to start or stop an instance’s database manager, DB2 applies the command to the current instance. DB2 determines the current instance as follows:

    - If the DB2INSTANCE environment variable is set for the current session, its value is the current instance. To set the DB2INSTANCE environment variable, enter:

    set db2instance=<new_instance_name>

    - If the DB2INSTANCE environment variable is not set for the current session, DB2 uses the setting for the DB2INSTANCE environment variable from the system environment variables. On Windows NT, system environment variables are set in System Environment. On Windows 9x, they are set in the autoexec.bat file.

    - If the DB2INSTANCE environment variable is not set at all, DB2 uses the registry variable, DB2INSTDEF. To set the DB2INSTDEF registry variable at the global level of the registry, enter:

    db2set db2instdef=<new_instance_name> -g

    To determine which instance applies to the current session, enter:

    db2 get instance
    Last edited by Marcus_A; 11-11-03 at 11:00.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  9. #9
    Join Date
    Jul 2003
    Posts
    50
    My computer has:
    Remote instance = dintadu/ADUDEV (on server C007473)
    Local instance = DB2 (on local computer C020517)
    -> See the jpeg-attachment on this reply.

    The problem is that I can't say explicitly to db2batch to attach to ADUDEV. I get a SQL1428N, see below:


    ---------------------------------------------
    --#SET PERF_DETAIL 3 ROWS_OUT 5

    Statement number: 1

    select count(*) from sysibm.systables

    1
    --------------
    290


    Number of rows retrieved is: 1
    Number of rows sent to output is: 1

    SQL1428N The application is already attached to "DB2" while the command issued
    requires an attachment to "ADUDEV" for successful execution.


    Elapsed Time is: 0.140 seconds


    Summary of Results
    ==================
    Elapsed Agent CPU Rows Rows
    Statement # Time (s) Time (s) Fetched Printed
    1 0.140 Not Collected 1 1

    Arith. mean 0.140
    Geom. mean 0.140
    Attached Thumbnails Attached Thumbnails db2batch.jpg  

  10. #10
    Join Date
    Nov 2004
    Posts
    2

    Solution

    I had exactly the same problem, which is why I found this page. Include the attach command in the batch. In my case, the batch was two commands

    CONNECT TO ccqa USER db2inst1 USING db2inst1
    GET SNAPSHOT FOR DATABASE ON ccqa

    and I got the same error message. Then I added

    attach to db2qa11 user db2inst1 using db2inst11

    to the start, and the error message was gone.

Posting Permissions

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