in reply to create table is not allowed with in a multi statement transaction

Afaict the prepare creates a stored procedure (or something similar) (at least with some database systems), and execute executes that.

So it seems that your database doesn't allow table creation in stored procedures.

A workaround is to try $dbh->do("create table test(id integer)");

Replies are listed 'Best First'.
Re^2: create table is not allowed with in a multi statement transaction
by vsudha (Initiate) on Jan 23, 2008 at 11:04 UTC
    hi,

    But with $dbh->do("create table #test(id integer)" also I am getting the same error, until and unless I keep AutoCommit attribute to 1. Is it mandatory to set AutoCommit value of dbh to be one to resolve this error.

    Thanks,
    Sudha
      create is an DDL statement which is enabled with autocommit so u need to set the value before executing the create.
        If I use $dbh->do(create table #test(id int)) to create temporary object in tempdb database. I am not able to see and perform operations in tempdb database on this table #test. It is giving error as "#test not found". But If I use $dbh->do(create table test(id int)) the table exists in my current database on which operations can be performed. Is there something which I am missing?