Skip site navigation (1) Skip section navigation (2)

Re: [INTERFACES] Create a database with ecpg

From: Michael Meskes <michael(at)fam-meskes(dot)de>
To: rodneyr(at)embratel(dot)com(dot)br
Cc: pgsql-interfaces(at)hub(dot)org
Subject: Re: [INTERFACES] Create a database with ecpg
Date: 1999-09-27 09:55:30
Message-ID: 19990927115530.A375@fam-meskes.de (view raw or flat)
Thread:
Lists: pgsql-interfaces
On Tue, Sep 21, 1999 at 10:15:33PM -0300, rodneyr(at)embratel(dot)com(dot)br wrote:
> "EXEC SQL CREATE DATABASE testbase;"
> 
> Then I compiled it, using ecpg, but the database was't been created.

In fact only a directory was created, right?

> When a try to open it with "psql" I receive the message:
> 
> Connection to database 'testbase' failed.
> FATAL 1:  Database testbase does not exist in pg_database
> 
> Is there any mistake in my statement?

Yes and no. The statement itself is correct. However, the usage is not. I
take it you are executing the statement inside a transaction but do not
issue a commit afterwards. Thus pg_database is not updated at all.

Please try calling EXEC SQL COMMIT; after the CREATE DATABASE call. This
should work. At least it does for me. 

Or call ecpg with parameter '-t' to switch off autotransaction mode. With
'-t' the CREATE DATABASE statement becomes a transaction for itself and thus
is committed once it returns.

Hope this helps.

Michael
-- 
Michael Meskes                         | Go SF 49ers!
Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
Email: Michael(at)Fam-Meskes(dot)De           | Use PostgreSQL!

In response to

pgsql-interfaces by date

Next:From: Anders SvenssonDate: 1999-09-27 12:35:46
Subject: Problem accessing databse via servlets
Previous:From: Dave PageDate: 1999-09-27 08:25:04
Subject: libpq.dll & psql.exe

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group