On Monday, February 15, 2016 at 1:38:33 PM UTC-8, Milutin Ivkovic wrote:
>
> DB["INSERT INTO test(bar) VALUES(?)", 'foo'].insert
>
> Always return null.
> I have alose tried to put `RETURNING id` on the end of query, but that 
> didnt help.
> Is there any solution for this ?
> And is this method faster then DB[:table].insert( :foo => bar ) ?
>

You probable want:

  DB["INSERT INTO test(bar) VALUES(?) RETURNING id", 'foo'].single_value

Yes, it is probably faster than having Sequel construct the SQL.  However, 
using a prepared statement for the insert will probably be faster still. 
 You just prepare the statement once, and then execute it every time you 
need it:

  INSERT_TABLE = DB[:table].prepare(:insert, :insert_table, :foo => :$foo) 
  INSERT_TABLE.call(:foo=>'foo')

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