You can trap the sql error code / msg and act accordingly...again possible through exceptions.