-
Like (0)
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
This seems to be saying that it is trying to convert 'B120' to a number. I assume that is because the column CFLSTPRN_MAILED_SEG_SUFF is a number in your source table.
All of the database columns are strings.
Robert
I have no other explanation, if that isn't it then there is a bug somewhere or something extremely odd is occurring:
create temp table foo (x integer);
CREATE TABLE
select * from foo where x = 'B120';
ERROR: pg_atoi: error in "B120": can't parse "B120"
Also I'm unsure what you are trying to do there:
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
x=`command` is going to trap the output of the nzsql command, not thre return code. I think what you intended is this:
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 $?
Rather than using -c "SQL statement" I prefer to use a HERE document, but either format works:
nzsql -vON_ERROR_STOP=1 <<-END
update OFFER_TBL_BULK_LOAD
set CFLSTPRN_SEGMENT_DESC = '${vals[1]}'
where CFLSTPRN_MAILED_SEG_ID = '${vals[2]}'
and CFLSTPRN_MAILED_SEG_SUFF = '${vals[3]}'
END
exit $?
Here is some more info:
The problem with the quote is the only one remaining:
ERROR: 'update ADMIN.OFFER_TBL_BULK_LOAD set CFLSTPRN_SEGMENT_DESC = 'CSM'S ' where..
note the three quotes.
I have made a temporary fix (removing the quote) for this, but I would like to find a better solution.
Thanks,
Robert Dannels

