Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2007
    Posts
    4

    Unanswered: Unix host variables

    Hi

    I want to get the a field from a SQL query into unix shell script variable. the whole situation is like this.

    1. Opened a cursor to a table in DB2 databse.
    2. Fetching individual rows with the help of cursor.
    3. Each row has 4 fields.

    I want each of the field in individual shell script variable.

    please provide the shell script code for the same.

    thanks

  2. #2
    Join Date
    Jun 2006
    Posts
    471
    something like this :
    db2 -x "select TABLESPACE_ID,CONTAINER_NAME,\
    case CONTAINER_TYPE when 0 then 'PATH' else 'FILE' end case ,\
    TOTAL_PAGES \
    from table( SNAPSHOT_CONTAINER('',-1)) as ts " | {
    while read TSREC
    do
    set - $TSREC
    ID=$1
    CN=$2
    CT=$3
    TP=$4
    .....
    done
    output of query will be stored in $ID - $CN-$CT-$TP and be handled with script statements..
    Best Regards, Guy Przytula
    DB2 UDB LUW certified V6/7/8

Posting Permissions

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