Is there a way to replace any error message to sc_alert()

I made a system to insert data from one table to another using run button, So if these data is exisitng it show error message like this:
"
SQLState: 23000 Error Code: 2601 Message: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Cannot insert duplicate key row in object ‘dbo.Emp_Accommodate’ with unique index ‘IX_Emp_Accommodate’. The duplicate key value is (100146). SQLState: 01000 Error Code: 3621 Message: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]The statement has been terminated.
INSERT INTO Emp_Accommodate (EmployeeNo, NameAr, Nationality_Ar, JobActual_Name, Project_Name, IqamaID_No, PassportNo, TelNo, Shift_Type, Room_IDF, House_IDF) SELECT EmployeeNo, NameAr, Nationality_Ar, JobActual_Name, Project_Name, IqamaID_No, PassportNo, TelNo, Shift_Type, Room_IDF, House_IDF FROM Employee WHERE EmployeeNo "

What I want is either a small message to appear instead of the previous one,
Or, the data is updated if there is duplicate in the data?

Kind regards

I think you could try sc_error_continue(“Event”)

See the SC manual:

1 Like

Thank you very much, So this my code how modify it to work very good
:arrow_down:
$arr=[i];
[selected][$arr]={EmployeeNo};
[i]++;

if(count([selected]) > 0)
{
$to_copy = implode(’,’,[selected]);
$sql = “INSERT INTO IDCard (EmployeeNo, EmployeeName, Nationality, Profession, Project, IqamaNo, PassportNo, Telephone, Room_IDF, House_IDF) SELECT EmployeeNo, NameAr, Nationality_Ar, JobActual_Name, Project_Name, IqamaID_No, PassportNo, TelNo, Room_IDF, House_IDF FROM Emp_Accommodate WHERE EmployeeNo =’$to_copy’”;
sc_exec_sql($sql);

[selected] = array();
}

🚀 Scriptcase 9.12 is now available! Check out the new features here 👉🚀 Next Monday (02/24), Scriptcase 9.12 will be released! Check out the new features before anyone else 👉