We have simple case, We have a table with column emailId i.e. unique.....using oracle DB
Question#1 Multiple concurrent user can check if some email id is available or not. Like 2 user that same time check availability of: abc@test.com
session1: select emailid from user_table; //If not present allow user to complete rest of the process & insert info
session2: select emailid from user_table;
Now both session will get that this email id (abc@test.com) is available & both try to insert, I know one of them will get error upon insertion BUT how we can make sure only 1 user get availability & other get not available upon select ??
Question#2 Also in case both sessions inserted the same value, then first will succeed, is there ways that 2nd session update that row instead of throwing error. Like we have another column for timestamp & want that 2nd session instead of throwing error simple update the timestamp column ?