Topic
  • 6 replies
  • Latest Post - ‏2012-11-06T21:07:11Z by W0C7_Edmond_Ko
W0C7_Edmond_Ko
W0C7_Edmond_Ko
9 Posts

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

    Re: DB2NODE environment variable question

    ‏2012-10-31T11:46:52Z  
    try this:

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

    Best regards
    Joachim
  • W0C7_Edmond_Ko
    W0C7_Edmond_Ko
    9 Posts

    Re: DB2NODE environment variable question

    ‏2012-10-31T14:34:21Z  
    • jmueller
    • ‏2012-10-31T11:46:52Z
    try this:

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

    Best regards
    Joachim
    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

    Re: DB2NODE environment variable question

    ‏2012-10-31T14:38:19Z  
    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 ____
    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
  • W0C7_Edmond_Ko
    W0C7_Edmond_Ko
    9 Posts

    Re: DB2NODE environment variable question

    ‏2012-11-01T14:51:09Z  
    • jmueller
    • ‏2012-10-31T14:38:19Z
    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
    no problem... thanks Joachim.
  • SystemAdmin
    SystemAdmin
    17917 Posts

    Re: DB2NODE environment variable question

    ‏2012-11-06T17:20:58Z  
    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 ____
    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

    Re: DB2NODE environment variable question

    ‏2012-11-06T21:07:11Z  
    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'
    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'