"Edmund Mergl" <[EMAIL PROTECTED]> writes:

> Jason E. Stewart wrote:
> 
> > Also, I'm interested in adding support for the builtin array
> > types. Do
>
> I prefer a patch

What I want is not to have to serialize my Perl arrays into strings
before passing them to execute() or do(), and not have to split() them
into arrays after a SELECT:

  my $sql = 'SELECT int_array_col FROM foo';
  my $ref = $dbh->selectall_arrayref($sql);
  foreach my $row (@{$ref->[0]}) {
    my @int_array_cols = @{$row}; # <= returns an array ref
  }

or

  my $sql = 'INSERT INTO foo (int_array_col) values (?)';
  my $sth = $dbh->prepare($sql);
  $sth->execute(\@array); # <= accepts an array ref

or

  my $sql = 'SELECT int_array_col FROM foo';
  my $sth = $dbh->prepare($sql);
  $sth->bind_col(1, \@array); # <= accepts an array ref
  $sth->execute();

So I have the first case working for int, float, and char array types
by modifying dbd_st_execute(). 

This issue that I've run into is that the bind mechanism seems to be
completely set up to handle only scalars, and it wants to convert
everything into a string.

Is this something fundamental with DBI, and I should give up, or is it
just something Pg specific? 

Thanks,
jas.

Reply via email to