Mark Thornber wrote:
> David,
>
> The way I got around this was to set the database name a empty string in
> the connect call.
>
> my $database = "";
> my $dbh = DBI->connect("DBI:Informix:$database", '', '', { ... } );
>
> Then one has a handle to use for $dbh->do( "create database fred" );
>
> (I'm using Perl 5.6, DBI 1.14, DBD-Informix-1.00.PC1 with Informix SE
> 7.24UC7 on Linux)
I think the documentation is supposed to cover that - ping me if it doesn't.
There are a couple of things you can do, all horrendously Informix
specific. Basically, you must avoid connecting to a specific database; you
must connect to just the database server. You can do that with either of
these:
$dbh = DBI->connect('dbi:Informix:@server',...);
$dbh = DBI->connect('dbi:Informix:.DEFAULT.',...);
The second effectively does:
$dbh = DBI->connect("dbi:Informix:\@$ENV{INFORMIXSERVER}",...);
One of the tests, a fairly early one, tries to create a database. Look at
that code too.
And finally, David and everyone, please include Informix in the subject line
-- I had 278 emails to process this evening, and it was only serendipity
that meant I got to read these messages at all. I have dumped a fairly
large number of emails into trash unread. I filter on Informix, and pay due
attention to messages mentioning it in the subject line.
> > Hollingworth David-dholli01 wrote:
> > I am using Perl version 5.00503 on Solaris 8 with the DBI::Informix
> > module (Informix V9.2).
> >
> > I want to be able to create a new database if it doesn't already exist
> > so I:
> >
> > 1. Connect to sysmaster
> > 2. Query sysdatabases for my database name
> > 3. It's not there so I "create database x with buffered logging"
> >
> > At which point it bombs with SQL: -759: Cannot use database commands
> > in an explicit database connection.
> >
> > The create doesn't work because I'm already connected to a database;
> > but in order to use the database driver I need a database handle and
> > to get a database handle I have to connect to a database (D'OH!).
> >
> > Is there any way to do this??
--
Jonathan Leffler ([EMAIL PROTECTED], [EMAIL PROTECTED])
Guardian of DBD::Informix 1.00.PC1 -- see http://www.cpan.org/
#include <disclaimer.h>