OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
AW: LOADERCLI reset SERIAL columns

From: Schildberg, Steffen (steffen.schildbergsap.com)
Date: Tue Mar 21 2006 - 04:27:48 CST


Hi Rosa,

Rosa Lago [mailto:rosa.lagogmail.com] wrote

> I have a problem with loadercli. After import catalog and data for
> the entire database using loadercli all columns that are of type
> serial(N) are reset to N when the import finish, so when I try to
> insert new rows for a table whose primary key is of type SERIAL(N)
> appears a duplicate key error. I have deleted the rows whose keys are
> N to test that it was the problem and in fact the problem is that.
>
> Can somebody help me?
>
Data type SERIAL is equivalent to FIXED(10) DEFAULT SERIAL (N).
So, to correct the behavior you could drop the DEFAULT SERIAL for every
table
that uses SERIAL and recreate it - a simple ALTER doesn't work.
An example would be the following definition (on the target system):
 CREATE TABLE example (c1 SERIAL(1), c2 CHAR(10))

Now drop the DEFAULT:
 ALTER TABLE example COLUMN c1 DROP DEFAULT
and recreate it with the value = highest inserted value + 1:
 ALTER TABLE example COLUMN c1 ADD DEFAULT SERIAL (<highest + 1>)

This should solve your problem. It sets the number generator to an
initial value
above the last/highest inserted.

As this is a shortcoming of the Loader we'll correct it to avoid those
problems
in the future.

Sorry for any inconvenience.
Regards,
 Steffen
--
Steffen Schildberg
MaxDB Team
SAP Labs Berlin

--
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb