Skip navigation
8799 Views 5 Replies Latest reply: Aug 25, 2010 9:56 AM by Robert Dannels RSS
Robert Dannels New Enzee 3 posts since
Aug 24, 2010
Currently Being Moderated

Aug 24, 2010 2:48 PM

How do I stop the Shell script from evaluating the string parameters to nzsql sql statements?

This simple update statement is failing due to spaces, quotes, slashes and "-" in the first input string:

 

#! /usr/bin/ksh
if [ $# -ne 3 ]; then
   rc=1
   echo "You must give exactly 3 values"
   exit 99
else
    vals[1]=$1
    vals[2]=$2
    vals[3]=$3
fi

 

if [ ${#vals[1]} -eq 0 ]; then
vals[1]='blank'
fi
x=1
x=`nzsql -vON_ERROR_STOP=1 -c "update ADMIN.OFFER_TBL_BULK_LOAD set CFLSTPRN_SEGMENT_DESC = '${vals[1]}' where CFLSTPRN_MAILED_SEG_ID = '${vals[2]}' and CFLSTPRN_MAILED_SEG_SUFF = '${vals[3]}';"`
exit $x

It gives this:

 

$ ./ldsegd "wart hog dead" "2004" "B120"
ERROR:  pg_atoi: error in "B120": can't parse "B120"

Please help,

 

Robert

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 4 points
  • Helpful Answers - 2 points