Tim Bunce a écrit : >> Does someone knows if it's possible to specify an array when executing a >> prepared statement ? > > The question seems confused...
Yes was difficult to explain ;-) >> $sth->execute(%array_data) > > %array_data isn't an array, it's a hash. > See http://perldoc.perl.org/perldata.html Yes absolutely, "associative array" i.e. "hash". I didn't developped in perl for a while... >> instead of : >> $sth->execute($array_data["firstname"],array_data["lastname"]) > > Square brackets are used to access array elements, but in that case the > value in the square brackets must be an integer. Oh yes sorry... > It looks like you're trying to use a hash. For that you'd use curly > braces, like this: > > $sth->execute( $hash_data{"firstname"}, $hash_data{"lastname"} ); > > Using 'hash slice' syntax (http://perldoc.perl.org/perldata.html#Slices) > you can shorten to: > > $sth->execute( @hash_data{"firstname", "lastname"} ); Ok I didn't know "hash slice" syntax, that's very interesting... What I want is to get the whole hash, therefore maybe what I want to do is this ? $sth->execute( @hash_data ); In fact I should explain what I am trying to do : #SELECT FROM database 1 and INSERT INTO database 2... while (@row = $sth_source->fetchrow_array()) { @array_data = @row; # INSERT $sth_pgsql->execute(@array_data) or die ; } What do you think ? Denis