On Tuesday, September 17, 2013 7:53:26 AM UTC-7, Ashley Cox wrote: > > Hi. > > I'm migrating existing systems over to Sinatra / Sequel and I have come > across an issue I can't find the solution in the documentation and the web > for. > I need to run the following query. > > > > INSERT INTO table(reply_id, created_by, message, created_at) > VALUES(?, ?, ?, ?) > > RETURNING id > INTO ? > > > I need to return the unique ID of the post (SK) into the reply_id of my > insert query. > So for example: > > ID: 1 > Reply ID: 1 (returned from the ID on insert) > Created By: Ash > Message: Fish and Chips > Created At: 2013-09-17 15:49 > > > In PHP I have used $sth->bindParam or in Perl $sth->bind_param_in_out > Is there something similar I can use in Sequel? >
Sequel doesn't support this (binding out params). However, you can set the sequence for the dataset (via Dataset#sequence), and upon insert, Sequel will look at the last value for the sequence to get the id of the inserted 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 http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/groups/opt_out.
