Not able to handle database insert errors.

Hi,
I am trying to use script case macros sc_error_insert after executing sc_execute_sql. I am trying to execute a database insert and if the database record already exist,
then i want to add my own logic based on error thrown from database without showing error to end user.

In this case, the screen is showing “error duplicate record with primary key” is coming as a popup box and not navigating to logic i wrote as follows.
Please advice how to handle database error handling when SQL query fails using script case.

// SQL statement parameters
$insert_table = ‘country’; // Table name

$v1 = “’” . {fname}. “’” ; //concatentae with single quotes for database.

$v2 = “’” . {Lname}. “’” ;

$insert_fields = array(
‘Code’ => {fname} ,
‘Name’ => {Lname}
);

$insert_sql = ‘INSERT INTO ’ . $insert_table
. ’ (’ . implode(’, ‘, array_keys($insert_fields)) . ‘)’
. ’ VALUES (’ . “’”. implode("’,’ ", array_values($insert_fields)) . “’”. ‘)’;

sc_error_continue(“insert”);

sc_exec_sql($insert_sql);

sc_error_continue(“insert”);

if (!empty({sc_error_insert}))
{
$tmp = strrpos({sc_error_insert}, “]”);
if ($tmp !== false)
{
{sc_error_delete} = “hello buddy” ;
}
sc_error_message(“hello ram”);

}

if( !empty({sc_error_insert}))
{
echo “same record already exists” ;
}
else
{
echo “duplicate record not exists and success” ;
}

Hi.
I’d be happy to know how you have finally handled your issue?