Results 1 to 4 of 4

Thread: assign a value

  1. #1
    Join Date
    Jun 2004
    Posts
    46

    Unanswered: assign a value

    I have to assign a result of a query to a vairable like this

    how can i do this

    Query = select count(*) from table
    x=`db2 ${Query}| sed -n '4p'`

    but this doesn't work, is there any other way to assign the result without redirecting the result to temp file. .

    Thanks
    Mark.

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool


    Maybe you need to use "quotes":
    Code:
    $ cat q0
    #!/bin/ksh
    . /db2/bin/db2_env.ksh
    Query='select count(*) from db2_tablespaces'
    x=`db2 "${Query}"|sed -n '4p'`
    echo "Result is: $x"
    exit
    $ q0
    Result is:       7
    $


    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Jun 2004
    Posts
    46
    Thanks, But still i am not getting value to x.

    if direct the result to a file and then print the result it is working otherwise
    i am getting following error.

    result is : SQL30082N Attempt to establish connection failed with security reason "3"

  4. #4
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool




    Security reason 3 is: PASSWORD MISSING (The request did not include a password)

    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

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