in reply to Record Count

Why not just do the update?
If the Affiliate_Number is 'bad' (not in the table)
then nothing happens and $RS->Recordcount will be zero.

I'd recomment creating a stored procedure on the DB
to do this and call that stored procedure from your perl.