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 702345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:42:38+00:00 2026-05-14T03:42:38+00:00

Using DBI::DatabaseHandle#execute or DBI::DatabaseHandle#prepare it’s not possible to run an sql script (with mutiple

  • 0

Using DBI::DatabaseHandle#execute or DBI::DatabaseHandle#prepare it’s not possible to run an sql script (with mutiple sql statments). It fails with the following error :

ERROR: cannot insert multiple commands into a prepared statement

I tried to use the “unprepared” way using DBI::DatabaseHandle#do (the doc says it “goes straight to the DBD‘s implementation”) but it keeps throwing the same error.

code snippet:

require 'dbd/pg'
require 'dbi'

DBI.connect("dbi:pg:database=dbname", db_user, db_password, db_params) do |dbh|
  schema = IO::read(schema_file)
  dbh.do(schema)
end

I’m using

ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]

dbi-0.4.3

dbd-pg-0.3.9

pg-0.9.0-x86-mswin32

Thank you!

  • 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-14T03:42:38+00:00Added an answer on May 14, 2026 at 3:42 am

    Running multiple queries using DatabaseHandle#do is a missing feature in DBD-Pg. See Ruby/DBI feature 28001.

    Note that Pg, the native postgresql Ruby driver on which DBD-Pg is based, allows running multiple queries.

    Example:

    require 'pg'
    require 'dbd/pg'
    require 'dbi'
    
    # Pg Succeeds
    PGconn.new({:host=>host,:user=>user,:password=>password,:dbname=>dbname}) do |conn|
      conn.exec("select 1; select 1;")
    end
    
    # DBD-Pg Fails with: ERROR: cannot insert multiple commands ...
    DBI::connect("dbi:pg:database=#{dbname};host=#{host};", user, password) do |dbh|
      dbh.do("select 1; select 1;")
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Perl's DBI module. I prepare a statement using placeholders, then execute the
I am writing a script using DBI to execute a select query to an
I'm trying to read data from SQL Server database using Perl and the DBI
I have a ruby script repeatedly executing the following the INSERT statement using the
I'm using perl DBI to connect to a SQL Server. This server uses windows
In R's DBI package, I'm not finding a facility for using bound variables. I
I'm using DBI for the first time (and not long started Perl [2 weeks])
I have a ruby script which I run using the JRuby Interpreter. The script
I have script that gets some data using DBI's fetchall_hashref(). Usually it returns a
I'm having a problem with executing a stored procedure from Perl (using the DBI

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.