Skip site navigation (1) Skip section navigation (2)

Getting real arrays from array fields in Perl

From: Alvar Freude <alvar(dot)freude(at)merz-akademie(dot)de>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Getting real arrays from array fields in Perl
Date: 2000-11-14 21:07:39
Message-ID: 3A11A99B.D3A0D0BE@merz-akademie.de (view raw or flat)
Thread:
Lists: pgsql-interfaces
Hello,

i have created a table containing arrays like this:

  CREATE TABLE arraytest
  (
    id SERIAL,
    array int8[],
    value text
  )

I use the DBI interface in Perl to handle the database. If i select
arrays in the database, it returns strings instead of real Perl array
refereneces:

  my $arrayref = $db_p->selectall_arrayref("SELECT * FROM arraytest");
  use Data::Dumper;
  print Dumper($arrayref);

The result is:

  $VAR1 = [
            [
              1,
              '{23,24,25,26}',
              'foo'
            ],
            [
              2,
              '{1,2,3,4}',
              'bar'
            ]
          ];

I want a structure containing real arrayrefs like this:

  $VAR1 = [
            [
              1,
              [ 23,24,25,26 ],
              'foo'
            ],
            [
              2,
              [ 1,2,3,4 ],
              'bar'
            ]
          ];

Is there an option to get the desired behaviour? I couldn't find
anything in the documentation of Postgres and DBD::Pg.


Thank you
Alvar

-- 
Alvar C.H. Freude  |  alvar(dot)freude(at)merz-akademie(dot)de

    Demo: http://www.online-demonstration.org/  |  Mach mit!
Blast-DE: http://www.assoziations-blaster.de/   |  Blast-Dich-Fit
Blast-EN: http://www.a-blast.org/               |  Blast/english

pgsql-interfaces by date

Next:From: Scott MuirDate: 2000-11-15 00:42:47
Subject: PGSQL and Image Magick
Previous:From: Adam LangDate: 2000-11-14 20:06:09
Subject: Re: OT: Heterogenous networks

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group