On Wednesday, December 20, 2017 at 7:56:33 AM UTC-8, Anonymous Testing 
wrote:
>
> Yup, I forgot to point that I used this method and it works properly, but 
> I need to add more params not related to another dataset. If I good 
> understand I need to add virtual rows to select statement with custom 
> values?
>

You probably want something like this: 

  DB[:table].insert([:column1, :column2, :column3], 
DB[:other_table].select(:other_column1, :other_column2, 
Sequel.as(param_value, :other_column3)))

However, such an approach can only work if you can generate a database 
expression for each param value.  If you need to execute ruby code to get 
param values per row, you'll have to use separate insert statements:

  DB.transaction do
    DB[:other_table].select(:other_column1, :other_column2).all do |row|
      DB[:table].insert(row.merge!(:column3=>param_value))
    end
  end

You can also use #multi_insert or #import to speed that process up, but the 
code is a little different for each.

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.

Reply via email to