Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: DBD::Pg insert data into an array

by pme (Monsignor)
on Dec 19, 2018 at 19:41 UTC ( [id://1227485]=note: print w/replies, xml ) Need Help??


in reply to DBD::Pg insert data into an array

This is how to do that in a more effective way, using prepare_cached().
my @data = ( ["A description", ["string 1", "string 2"], [ 1, 2, 3]], ["B description", ["string 3", "string 4"], [ 4, 5, 6]], ["C description", ["string 5", "string 6"], [ 7, 8, 9]], ["D description", ["string 7", "string 8"], [10,11,12]], ); my $sth = $dbh->prepare_cached("insert into my_table(description, asso +ciated_str_data, associated_int_data) values (?, ?, ?)"); $sth->execute(@$_) for @data; $dbh->commit;

Replies are listed 'Best First'.
Re^2: DBD::Pg insert data into an array
by rdfield (Priest) on Dec 19, 2018 at 21:00 UTC
    In a batch environment, yes, your way might be more effective - but in a batch environment I'd question the wisdom of burying data inside an array column.

    rdfield

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1227485]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-25 22:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found