if /local/bin/wsname 2>/dev/null; then # run wsname discarding its err msgs and check the exit code; if 0 then
base="`/local/bin/wsname`" # assign the output of wsname to...
This is telling you that you have defined the tables with a column that must be unique and you are trying to insert a record that duplicates the value in this column of another record.