Re: create table inside a transaction - Mailing list pgsql-jdbc

From Nicholas Rahn
Subject Re: create table inside a transaction
Date
Msg-id 1064850593.1865.83.camel@frisbee.mnc.ch
Whole thread Raw
In response to create table inside a transaction  (Tim McAuley <mcauleyt@tcd.ie>)
List pgsql-jdbc
Hi,

I ran into this same error last week.  My very inelegant solution was
this:

  <!-- Create the database. -->
  <exec executable="/usr/local/pgsql/bin/createdb"
        failonerror="true">
    <arg value="-E"/>
    <arg value="UNICODE"/>
    <arg value="-U"/>
    <arg value="postgres"/>
    <arg value="mydb"/>
  </exec>

But, it would be nice to have something a bit "cleaner".

Nick


On Mon, 2003-09-29 at 16:27, Tim McAuley wrote:
> Hi,
>
> I am testing out Postgresql 7.4 beta3 (with appropriate jdbc driver) and
> have come across an interesting little problem.
>
> According to some comments on the web, statements such as "CREATE TABLE"
> should not be run within a transaction. However, it is this very
> statement that I am running from an sql ant task and I get the following
> error:
>
> BUILD FAILED
> build.xml:257: org.postgresql.util.PSQLException: ERROR: CREATE DATABASE
> cannot run inside a transaction block
>
> Any ideas how to overcome this? My thoughts are:
>
> - This message has obviously been upgraded to through an error in 7.4
> - The sql call in the ant task is not in a <transaction> element.
>     - however, ant will still place all the sql code in a single
> transaction.
>
> To overcome this I think the options are:
> 1 Modify ant code so that an sql ant task can be called without using a
> transaction at all.
> 2 Ensure postgresql does not through this as an error (or the jdbc driver?)
> 3 Create own code (or ant task) that can run sql commands without using
> transactions.
>
> Just wondering what other people have done and what may be seen as the
> best solution. Personally I would like if Ant had the option to disable
> transactions altogether. This would seem the neatest and most "correct"
> option.
>
> All the best,
>
> Tim
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faqs/FAQ.html
>


pgsql-jdbc by date:

Previous
From: Tim McAuley
Date:
Subject: create table inside a transaction
Next
From: Germán Gazzoni
Date:
Subject: Tomcat - PostgreSQL - Perfomance Tunning