Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6567997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:24:11+00:00 2026-05-25T14:24:11+00:00

I have a prepared insert statement in Sequel (using Oracle). prepared_statement = DB[:table_name].prepare(:insert, :name,

  • 0

I have a prepared insert statement in Sequel (using Oracle).

prepared_statement = DB[:table_name].prepare(:insert, :name, :value=>:$value)

When I call it the row gets added just fine.

prepared_statement.call :value=>'Some value'

I have a trigger and a sequence set up so the ID will be auto generated. I would like to get back the row (or the id) I just added, but I can’t see how. I can’t use insert because value is a CLOB and may be greater than 4000 characters.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:24:12+00:00Added an answer on May 25, 2026 at 2:24 pm

    In JRuby, using the JDBC adapter you can override the insert and pass in the returning clause. The tricky part is that you don’t always know what the primary key is at this level so you may have to use ROWID or request all of the columns back.

    You end up with something that looks similar to this:

    module Sequel
      module JDBC
        class Database
          def execute_insert_with_returning(conn, sql, opts = {})        
            columns = opts[:key_columns] || ["ROWID"]
            q = "{ call #{sql} returning #{columns.join(',')} into #{columns.collect {|_| '?'}.join(',')} }"
            stmt = conn.prepare_call(q)
            raise "Unable to prepare call for insert" if stmt.nil?
    
            begin
              columns.each_with_index do |_, index|
                stmt.registerOutParameter(index+1, JavaSQL::Types::VARCHAR)
              end
              return nil if 0 == stmt.executeQuery
    
              values = (1..columns.count).inject({}) do |memo, index|
                key = columns[index-1].downcase.to_sym rescue nil
                memo[key] = stmt.get_string(index) unless key.nil?
                memo
              end
              values
            ensure
              stmt.close
            end
          end # #execute_insert_with_returning
    
          alias execute_without_specialized_insert execute
          def execute(sql, opts={}, &block)
            if opts[:type] == :insert
              synchronize(opts[:server]) do |conn|
                execute_insert_with_returning conn, sql, opts
              end
            else
              execute_without_specialized_insert sql, opts, &block
            end
          end # #execute
        end # Database
      end # JDBC
    end # Sequel
    

    I’ve done something pretty much like this and it works pretty good. I think we had to override the Sequel::Model as well so it passes the primary key in as opts[:key_columns] but I may be remembering incorrectly.

    This is a bit of a load bearing kludge that gets the job done. It would be more elegant to specialize it to the Oracle JDBC adapter and to ensure that all of the error handling code is present from the original execute statement. Given the time I’d love to get something better and give it back to the Sequel project.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to have a MySQLi prepared statement within the fetch() call of
I Have a prepared statement INSERT INTO mst(time) VALUES (?); where time is of
we have problem with slow insert statement using 40 bind variables as columns values.
Lets assume I have this long insert statement insert into table1 (id, name, phone,
I have a C# application that is having issues using a prepared statement with
The JDBC 3.0 spec talks about Connection (and Prepared Statement) pooling. We have several
I have a SqlCommand that I want to call Prepare() on whose CommandType =
I have a simple insert select which insert _TABLE_B_ data in _TABLE_A_ new row
I am using the Informix.NET driver (C#) to insert a row into a database
I want to use prepared statement to insert and update data in mysqli, Below

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.