Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: DBD::Pg insert data into an array

by pme (Prior)
on Dec 19, 2018 at 19:41 UTC ( #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
Node Status?
node history
Node Type: note [id://1227485]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2019-12-12 11:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?