Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
6 replies Latest Post - ‏2012-11-06T21:07:11Z by W0C7_Edmond_Ko
W0C7_Edmond_Ko
W0C7_Edmond_Ko
9 Posts
ACCEPTED ANSWER

Pinned topic DB2NODE environment variable question

‏2012-10-30T21:32:35Z |
I have newbie question about the DB2NODE environment variable.
I'm working on a multi-partition database which has 24 partitions.
When I run...

db2_all 'echo $DB2NODE'

I get a return of 1, 2, 3, 4, ..., 24 for each database partition.

Is there an equivalent environment variable that will return 4 digits?
ie. 0001, 0002, 0003, 0004, ... , 0024
Updated on 2012-11-06T21:07:11Z at 2012-11-06T21:07:11Z by W0C7_Edmond_Ko
  • jmueller
    jmueller
    71 Posts
    ACCEPTED ANSWER

    Re: DB2NODE environment variable question

    ‏2012-10-31T11:46:52Z  in response to W0C7_Edmond_Ko
    try this:

    db2_all "\" echo DB_Partition = 000## ____;"

    Best regards
    Joachim
    • W0C7_Edmond_Ko
      W0C7_Edmond_Ko
      9 Posts
      ACCEPTED ANSWER

      Re: DB2NODE environment variable question

      ‏2012-10-31T14:34:21Z  in response to jmueller
      Thanks Joachim, works great until I get into the higher numbers.

      DB_Partition = 0001 ____
      DB_Partition = 0002 ____
      ....
      DB_Partition = 00022 ____
      DB_Partition = 00023 ____
      DB_Partition = 00024 ____

      Is there any way to only return 4 digits only?
      For example:

      DB_Partition = 0001 ____
      DB_Partition = 0002 ____
      ....
      DB_Partition = 0022 ____
      DB_Partition = 0023 ____
      DB_Partition = 0024 ____
      • jmueller
        jmueller
        71 Posts
        ACCEPTED ANSWER

        Re: DB2NODE environment variable question

        ‏2012-10-31T14:38:19Z  in response to W0C7_Edmond_Ko
        Sorry, it's my mistake. We have only 6 Partitions. I believe you can work with awk or sed, but this is not my competence.

        Best regrads,
        Joachim
      • SystemAdmin
        SystemAdmin
        17917 Posts
        ACCEPTED ANSWER

        Re: DB2NODE environment variable question

        ‏2012-11-06T17:20:58Z  in response to W0C7_Edmond_Ko
        If it's available in your environment, something like a simple Korn shell 'printf' does the trick nicely.

        db2_all 'fmt=$(printf %04d $DB2NODE); echo $DB2NODE = $fmt'
        • W0C7_Edmond_Ko
          W0C7_Edmond_Ko
          9 Posts
          ACCEPTED ANSWER

          Re: DB2NODE environment variable question

          ‏2012-11-06T21:07:11Z  in response to SystemAdmin
          Thanks Kelly.
          It works like a charm.

          btw. I was playing around with this and it seem to do the trick as well.
          db2_all 'export db2node4=$DB2NODE; typeset -Z4 db2node4; echo $DB2NODE $db2node4'