Hello,

In my test script below, i am trying to figure out how to suppress the error 
mesg when the the script try to add a previously presen tentry into the table.

OR better even, to make sure that the script should not even try to update the 
table, if the record is already present in table. (table may grow very big in 
future).

table:
Action
Keyname
Type
Unique
Packed
Column
Cardinality
Collation
Null
Comment
 Edit  Drop 
PRIMARYBTREE Yes No userid 3 A 
 
 
 Edit  Drop 
useridBTREE Yes No userid 3 A 
 
 

mysql> desc testdbusers;
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| userid   | char(6)     | NO   | PRI | NULL    |       |
| password | varchar(10) | YES  |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

mysql> 


mysql> show index from testdbusers;
+-------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table       | Non_unique | Key_name | Seq_in_index | Column_name | Collation 
| Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+-------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| testdbusers |          0 | PRIMARY  |            1 | userid      | A         
|           3 |     NULL | NULL   |      | BTREE      |         |
| testdbusers |          0 | userid   |            1 | userid      | A         
|           3 |     NULL | NULL   |      | BTREE      |         |
+-------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
2 rows in set (0.00 sec)

mysql> 





script:

#!/usr/bin/perl
use strict;
use warnings;
use lib '../testdb';
use Mysqltestdb::Schema;
my $schema;
my @newusers;
$schema = 
Mysqltestdb::Schema->connect("dbi:mysql:dbname=mysqltestdb:localhost:3306", 
'root', 'mypassword');
@newusers = (['te1234', 'pass'], ['te4567', 'pass']);

$schema->populate('Testdbuser', [
   [qw/userid password/],
   @newusers,
]);




I get this info message out from script(error):


DBIx::Class::Schema::populate(): Duplicate entry 'te1234' for key 'PRIMARY' for 
populate slice:
{
  password => "pass",
  userid => "te1234"
}
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to