how to check the duplicate key in mysql dbi Perl?

Problem :

I am trying to migrate data from one db1 to other db2.

While migrating, there is possibility of duplicate primary key, then i want to over write with the db1 values. This can be achieved by on duplicate key sql statement.

But i want to store duplicate entry key into a map? how it is possible?

This is code which i have written for migration:

my $select = $dbh1->prepare("SELECT pr_id, name, lastname FROM person");
my $insert = $dbh2->prepare("INSERT INTO PERSON(pr_id, name, last_name) VALUES (?,?,?)");

while ( my($PR_ID,$NAME,$LASTNAME) = $select->fetchrow_array )

Solution :

You may need to call the following function to do it.

Returns the native database engine error message from the last DBI method called.

Refer to:

Mysql Tutorials

Mysql Howto..

How to add a string containg a double quote to a sql database?

How to create log activity from java to MySQL?

MySQL considers 'е' and 'ё' equal, how do I set it to consider them different?

How to return a specific field from a SQL database within an Visual Studio (.net) developed program

How to find wrong order in MySQL?

how to change (Update) column name in table using MySQL workbench?

How to join two mysql tables that are mostly different, and sort by two columns at once?

How to sort data in mysql UNION subquery?

How to check if record deleted was last record left MySQL PHP

POSTGRE how to select parent name from hierarchical table

how to find index of the first capital letter in mysql, cyrillic characters

Doctrine 2: how to auto-get data of related tables?

How to get complete row when using max(points) AS in mysql?

How to copy the tables of an existing MySQL database to a new database without the records?

How do you version your database schema?

How To Store localstorage Array Into MySQL Database?

How to display stored url in database to a webpage? [closed]

How to join my mysql table

How to convert a MS SQL Merge Query to work with MySQL DB? [closed]

How to enable TCP on MAMP?

How to make a field in a table reference to another table in MySQL/MariaDB?

How to calculate or see the performance of my database in mysql?

how to select Count of Ranges from mysql table?

How do I find a table in MySQL with 2 specific columns in it

bash how to print for loop output into one line?

How to get groups of rows in MySQL and Cassandra

How to select records that match values in one column and don't in other column in MySql?

How to search for existence of record in one table from another using php and mysql

How to explode user id from a database column?

How to get data from date and time range in MySQL