Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

DBD::Pg insert data into an array

by rdfield (Priest)
on Dec 19, 2018 at 17:59 UTC ( [id://1227477]=CUFP: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    create table my_table(
    id serial,
    description varchar(255),
    associated_str_data varchar(255)[],
    associated_int_data integer[]);
    
  2. or download this
    my $desc = "A description";
    my @assoc_str_data = ("string 1", "string 2");
    my @assoc_int_data = (1,2,3);
    $dbh->do("insert into my_table(description, associated_str_data, assoc
    +iated_int_data) values (?,?,?)",
             undef, $desc, \@assoc_str_data, \@assoc_int_data);
    
  3. or download this
    # select * from my_table;
     id |  description  |   associated_str_data   | associated_int_data
    ----+---------------+-------------------------+---------------------
      2 | A description | {"string 1","string 2"} | {1,2,3}
    (1 row)
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://1227477]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2024-04-18 16:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found