$upd_sql = "UPDATE table SET [Field1]=?, [Field2]=?, [Field3]=? where Field0=?"; $ins_sql = "INSERT INTO table ( [Field1], [Field2], [Field3], [Field0] ) VALUES ( ?, ?, ?, ? )"; $sth = $dbh->prepare($exists ? $ins_sql : $upd_sql); $sth->execute( 'stringvalue', numericvalue, booleanvalue, index, );