You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Guillaume Barré <Gu...@technomedia.ca> on 2004/03/08 20:52:48 UTC

HyperSonic and primaryKey

HI

 

A sql problem with hypersonic.

 

My schema file looks like : 

 

<table javaName="CourseSupplier" name="CMS_COURSE_SUPPLIERS" idMethod="native">

<column javaName="Id" name="ID" primaryKey="true" required="true"  autoIncrement="true"  type="INTEGER"/>

            <column javaName="ContactFirtName" name="CONTACT_FIRST_NAME" size="50" type="VARCHAR"  />

            <column javaName="ContactLastName" name="CONTACT_LAST_NAME" size="50" type="VARCHAR" />

            <column javaName="ContactEmail" name="CONTACT_EMAIL" size="50" type="VARCHAR" />

</table>

 

And the gemerated SQL code is : 

 

CREATE TABLE TEST_COURSE_SUPPLIERS
(
    ID integer IDENTITY,
    CONTACT_FIRST_NAME VARCHAR (50),
    CONTACT_LAST_NAME VARCHAR (50),
    CONTACT_EMAIL VARCHAR (50),
    PRIMARY KEY(ID)
);

 

 

My problem is that when I create the table on HyperSonic I have the following error  

 

Erreur Attempt to define a second primary key in statement ... Error code 24 / State S0011

 

Any idea ?

 

Thanks in advance

Guillaume

 


Re: HyperSonic and primaryKey

Posted by Andras Salamon <as...@hu.inter.net>.
On Mon, 8 Mar 2004, [iso-8859-1] Guillaume Barré wrote:

Hi,

> HI
> 
>  
> 
> A sql problem with hypersonic.
> 
>  
> 
> My schema file looks like : 
> 
>  
> 
> <table javaName="CourseSupplier" name="CMS_COURSE_SUPPLIERS" idMethod="native">
> 
> <column javaName="Id" name="ID" primaryKey="true" required="true"  autoIncrement="true"  type="INTEGER"/>
> 
>             <column javaName="ContactFirtName" name="CONTACT_FIRST_NAME" size="50" type="VARCHAR"  />
> 
>             <column javaName="ContactLastName" name="CONTACT_LAST_NAME" size="50" type="VARCHAR" />
> 
>             <column javaName="ContactEmail" name="CONTACT_EMAIL" size="50" type="VARCHAR" />
> 
> </table>
> 
>  
> 
> And the gemerated SQL code is : 
> 
>  
> 
> CREATE TABLE TEST_COURSE_SUPPLIERS
> (
>     ID integer IDENTITY,
>     CONTACT_FIRST_NAME VARCHAR (50),
>     CONTACT_LAST_NAME VARCHAR (50),
>     CONTACT_EMAIL VARCHAR (50),
>     PRIMARY KEY(ID)
> );
> 
>  
> 
>  
> 
> My problem is that when I create the table on HyperSonic I have the
> following error
> 
>  
> 
> Erreur Attempt to define a second primary key in statement ... Error
> code 24 / State S0011
> 
>  
> 
> Any idea ?
>

IDENTITY type will create an automatic primary key, so there is 2 primary 
keys on ID column.

Turn off something (autoincrement or primary key). Since I always use 
autoincrement on my primary keys, I changed the template 
(hypersonic/primarykey.vm):

#if ($table.hasPrimaryKey() && ($table.IdMethod != "native"))    
    PRIMARY KEY($table.printPrimaryKey()),
#end

So it will not create primary key if the idMethod is native.

Hope this helps,

Sala
 
>  
> 
> Thanks in advance
> 
> Guillaume
> 
>  
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org