On Thursday, April 27, 2017 at 12:09:01 PM UTC-7, [email protected] wrote: > > Hello, > > I've been searching through the docs and experimenting but I haven't found > anything. > I'm wondering if there is a way to create a prepared statement for > multi_insert so that I can do something like: > DB[:tablename].prepare(:multi_insert, :insert_from_list, :values =>: > $list_of_hashes) > And then call this with: > DB.call(:insert_from_list, :values => [{:col1 => val1}, [{:col1 => val11, > :col2 => val12}, {:col1 => val21, :col1 => val22}]) > Or at least something along those lines. > Is there a way to do this with Sequel? >
No, that isn't supported by Sequel, or by any SQL database I am aware of (in the sense of the SQL server supporting a bound variable that accepts an array of rows). Each separate column value needs a separate bound variable. I would just call DB[:tablename].multi_insert instead of trying to use a prepared statement for this, or use a prepared statement for a single insert that is called for each row. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
