Array data and the Perl DBI

From: Kathy Smith <ksmith(at)lanl(dot)gov>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Array data and the Perl DBI
Date: 2004-07-01 23:30:40
Message-ID: 6.0.3.0.2.20040701171811.02921908@nis-pop.lanl.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

I am having problems retrieving data stored in arrays using the Perl
DBI. I have noticed some others have had problems like this, and it looked
like some fixes were forthcoming. I know how to kludge a fix by specifying
each element of the array separately in the query, but that is an
unacceptable solution for me. I want to know if there's any way to get
this to work as advertised. It fails on the fetch - segmentation
fault. Thanks, Kathy

#***********************************************Code***************************
#!/packages/bin/perl
use DBI;

my
$dbh=DBI->connect("dbi:Pg:host=$host;dbname=$db;user=$user;password=$passwd");
my $statement="select channels[2] from test_array where ta_key='A'";
my $sth=$dbh->prepare($statement);
$sth->execute();
@answer=$sth->fetchrow_array;
$rc=$sth->finish;
$dbh->disconnect;

#******************************************Table definition
*************************
#Table definition
CREATE TABLE test_array (
ta_key char(1) not null,
channels numeric(10,4) []
);

insert into test_array (ta_key,channels) values
('A','{1.93,2.0,3.5,5.0,5.666}');

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message jason_e_stewart 2004-07-02 07:09:40 DBD::Pg and $sth->{ParamValues}
Previous Message Marc G. Fournier 2004-07-01 23:24:27 Re: pgFoundry Open For Business