Re: [INTERFACES] ODBC CREATE TABLE failures

From: "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>
To: "Michael J(dot) Sheldon" <msheldon(at)cbrcomm(dot)com>
Cc: "'pgsql-interfaces(at)postgresql(dot)org'" <pgsql-interfaces(at)postgreSQL(dot)org>
Subject: Re: [INTERFACES] ODBC CREATE TABLE failures
Date: 1999-01-01 05:40:56
Message-ID: 368C5FE8.5032023A@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

> The application will automatically create the database structure if it
> does not already exist
> However, only the first table is being created.
> Code follows:
<snip>

You can test this code by running it through psql, and it fails there
too. Each CREATE TABLE statement is trying to use the same label for the
primary key constraint, but since Postgres enforces the primary key by
generating an implicit index this fails. Try using unique names for
constraints!

If for some reason these constraint names *must* be identical, you could
consider modifying the code in the parser to generate a unique internal
name based on both the constraint name and the table name, for example.
There is already a routine there to help you do this.

Failure example follows...

- Tom

postgres=> CREATE TABLE FMGroups
postgres-> (
postgres-> GroupID INTEGER NOT NULL,
postgres-> GroupName VARCHAR(64) NOT NULL,
postgres-> Description VARCHAR(100),
postgres-> CONSTRAINT ID_pk PRIMARY KEY (GroupID),
postgres-> CONSTRAINT check_directory UNIQUE (GroupName)
postgres-> );
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index id_pk for
table fmgroups
NOTICE: CREATE TABLE/UNIQUE will create implicit index check_directory
for table fmgroups
CREATE
postgres=> CREATE TABLE FMDirectories
postgres-> (
postgres-> DirectoryID INTEGER NOT NULL,
postgres-> DirectoryName VARCHAR(64) NOT NULL,
postgres-> Description VARCHAR(100),
postgres-> ParentID INTEGER NOT NULL,
postgres-> CONSTRAINT ID_pk PRIMARY KEY (DirectoryID),
postgres-> CONSTRAINT check_directory UNIQUE (DirectoryName)
postgres-> );
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index id_pk for
table fmdirectories
NOTICE: CREATE TABLE/UNIQUE will create implicit index check_directory
for table fmdirectories
ERROR: Cannot create index: 'id_pk' already exists

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message David Hartwig 1999-01-01 06:10:41 Re: [INTERFACES] ODBC CREATE TABLE failures
Previous Message Sergio 1999-01-01 05:29:44 Re: [INTERFACES] yet another postgresql interface