Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2010
    Posts
    1

    Thumbs up Unanswered: How to assign the value of a sybase variable to a shell script variable ?

    Hi All,

    This is script that I ve written to delete a table in chunks .. I want the value got through @myvariable to be stored in myvariable .. But dont know how it is done ..
    echo `date`
    count=1
    myvariable
    while (true)
    do
    isql -Urts -Prwa3 -SSUN02 -Daep1 -c -w300 -ochunk_test1 <<!
    set rowcount 300

    begin transaction

    declare @myvariable int
    select @myvariable=count(*) from SAO_SA_ORDR,DCB_DATA_CLSNG_BP where SAO_ORDR_ISSR <> DCB_BP_ID
    select SAO_SA_ORDR_ID,SAO_ORDR_ISSR
    from
    SAO_ORDR,DCB_DATA_CLSNG_BP
    where SAO_ISSR=DCB_BP_ID
    commit
    $myvariable=select @myvariable
    !
    count=`expr $count + 1`
    if [ $count -eq '$myvariable/300' ]
    then
    echo "Script completed!!!"
    echo `date`
    exit
    fi
    done
    echo `date`

    Thanks is advance

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    No easy way
    grep from the log file e.g.
    x=$(grep 'xxx' chunk_test1)

    maybe adapt this
    Code:
    #!/bin/ksh
    getcnt() {
    isql -Urts -Prwa3 -SSUN02 -Daep1 -b <<!
    set nocount on
    select count(*) from sysobjects where type='$1'
    go
    !
    }
    echo "count of user tables: $(getcnt U)"
    echo "count of sys tables : $(getcnt S)"

Posting Permissions

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